I have a PHP script that generates large zip files, when I execute it via SSH it works, but the same script fails intermittently when executed via cron.
Things I tried:
- Changing paths inside the script, but since it executes via SSH it shouldn't be the issue
- Changing path to the PHP executable inside the cron command (I ran "whereis php" and used the 2 available PHP executable locations)
- Modified file permissions
- Put time limit as ini_set('max_execution_time', 990000); and via set_time_limit (990000);
- Half a dozen support tickets with the hosting company, but they can't help
Last thing I'm trying right now, which I don't think will help is manually setting a time limit after which the cronjob will fail by including: /bin/timeout -s 2 990000 but I think it's useless since normally there are no timelimits, unless I'm missing something.
Log file shows that the script fails after I instantiate an object from class ZipArchive and then try to execute the addFile method.
This is my current cron command:
30 4 * * * /bin/timeout -s 2 990000 /usr/bin/php /home/script.php > /tmp/script.log
Appreciate your help.