shell_exec wont work from crontab

谁都会走 提交于 2019-12-12 03:16:50

问题


I have looked at other answers they dont fit to this case. I am using the full path to the file. Code I copied is simplified.

run.php contains:

shell_exec("php /var/www/html/sync/chourly.php $position $quotientx > /dev/null 2>/dev/null &");

if I use manually php run.php - it works great. here is the line on crontab -e :

05 * * * *  /usr/bin/wget -O /dev/null http://sync.eeeww.com/run.php

again the file run.php starts BUT chourly.php doesn't start. I am using centOS 6 any suggestions please? Addition: I checked the permissions I am using ec2-user to run php run.php and crontab is using the same permission. it is able to run the file but shell_exec is where the issue occurs


回答1:


Is /var/www/html/sync/chourly.php using $SERVER['DOCUMENT_ROOT'] ? Since you're explicitly calling the php interpreter (not mod_php), a `$SERVER['DOCUMENT_ROOT'] call will not work as you expect.

Try manually running the cron from shell to see where it's failing.

cd /
su - your_httpd_usersame -c "/usr/bin/wget -O /dev/null http://sync.bitpine.com/run.php"


来源:https://stackoverflow.com/questions/27806488/shell-exec-wont-work-from-crontab

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!