shell_exec不工作从crontab [英] shell_exec wont work from crontab
问题描述
我已经看过他们不适合这种情况的其他答案。
我使用文件的完整路径。代码复制已被简化。
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包含:
run.php contains:
shell_exec("php /var/www/html/sync/chourly.php $position $quotientx > /dev/null 2>/dev/null &");
< - 它的工作伟大。
这里是crontab -e上的行:
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
.php启动BUT chourly.php不启动。我使用centOS 6
任何建议吗?
添加:我检查了权限,我使用ec2-user运行php run.php和crontab使用相同的权限。它可以运行该文件,但shell_exec是发生问题的地方
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
推荐答案
Is / var / www / html / sync / chourly .php使用 $ SERVER ['DOCUMENT_ROOT']
?因为你显式调用php解释器(而不是mod_php),一个`$ SERVER ['DOCUMENT_ROOT']调用将无法正常工作。
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.
尝试手动运行
cd /
su - your_httpd_usersame -c "/usr/bin/wget -O /dev/null http://sync.bitpine.com/run.php"
这篇关于shell_exec不工作从crontab的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!