I have a strange issue with PHP running inside a jail when calling the php script using cron.
The output of the script is:
If I run the script directly from shell without using cron then it runs fine.
Also if I use cronjob but I change the temporary dir to "/home/sites2/tmp" then it works fine:
The jail is inside /home/jail/jail1 and the host /home is mounted as nosuid. The /tmp is mounted in jail using nullfs. If I remove the nosuid from host /home then the script works fine using the first cronjob.
Truss shows something about broken pipe before the script shows fatal error and stops running.
To summarize:
1) If I run the script from jail directly from console it works.
2) If I remove nosuid from host /home then running script using cron works.
Any idea why this happens?
Code:
*/5 * * * * /usr/local/bin/php -d memory_limit=4096M /home/www/sites2/example.com/www/magento_softone/sync_images.php >> /home/www/sites2/out.txt
The output of the script is:
Code:
Warning: rename(/tmpfs/1040ca8.989258eea54e4c1301732ecbd23c2c4a.jpg,/home/www/sites2/example.com/www/pub/media/tmp/catalog/product/9/8/989258eea54e4c1301732ecbd23c2c4a.jpg): Operation not permitted in /home/www/sites2/example.com/www/lib/internal/Magento/Framework/File/Uploader.php on line 298
Fatal error: Uncaught Magento\Framework\Exception\StateException: The product can't be saved. in /home/www/sites2/example.com/www/app/code/Magento/Catalog/Model/Product/Gallery/GalleryManagement.php:77
Stack trace:
#0 /home/www/sites2/example.com/www/magento_softone/sync_images.php(228): Magento\Catalog\Model\Product\Gallery\GalleryManagement->create('BENT.0328-\xCE\x9B\xCE\x95\xCE...', Object(Magento\Catalog\Model\Product\Gallery\Entry))
#1 {main}
thrown in /home/www/sites2/example.com/www/app/code/Magento/Catalog/Model/Product/Gallery/GalleryManagement.php on line 77
If I run the script directly from shell without using cron then it runs fine.
Also if I use cronjob but I change the temporary dir to "/home/sites2/tmp" then it works fine:
Code:
*/5 * * * * /usr/local/bin/php -d memory_limit=4096M -d sys_temp_dir="/home/sites2/tmp" /home/www/sites2/example.com/www/magento_softone/sync_images.php >> /home/www/sites2/out.txt
The jail is inside /home/jail/jail1 and the host /home is mounted as nosuid. The /tmp is mounted in jail using nullfs. If I remove the nosuid from host /home then the script works fine using the first cronjob.
Truss shows something about broken pipe before the script shows fatal error and stops running.
To summarize:
1) If I run the script from jail directly from console it works.
2) If I remove nosuid from host /home then running script using cron works.
Any idea why this happens?