![](/img/trans.png)
[英]Linux command not working from PHP website but working from terminal
[英]at command for linux job not working from php
我有一个带有curl命令的脚本.sh
:
curl --digest "http://xxxxxxx.xxx/mail.php?email=xxxx@xxx.xx";
从终端这很好:
./script.sh #(mail arrives in my box)
从PHP这很好的工作:
shell_exec('./phpsc.sh'); // (mail arrives in my box)
从终端这很好用:
at -f phpsc.sh now + 5 minute
# (job created, mail arrives in my box after 5 minutes)
从PHP这将无法正常工作:
shell_exec('at -f phpsc.sh now + 5 minute'); //:( :(
甚至当我把at
脚本命令,并从PHP的运行脚本at
命令,它会被忽略:(
我找到了解决方案,
我从/etc/at.deny中删除了www-data ,现在'at'comand从php(sell_exec)正常工作
我知道有时有时需要使用source
来调用环境变量。
这是您应该尝试的方法(如果您使用的不是ksh,则应进行调整):
shell_exec('source ${HOME}/.kshrc ; at -f phpsc.sh now + 5 minute');
在CentOS 7中,我必须在/etc/at.allow中添加“ apache”。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.