原文网址:https://www.youyong.top/article/1158e72ae1125
Linux Crontab 执行 PHP 程序失败
原文网址:https://www.youyong.top/article/1158e72ae1125
Linux Crontab 执行 PHP 程序失败
原文网址:https://www.youyong.top/article/1158e72ae1125
云服务器 ECS Linux Crontab 执行 PHP 程序失败。例如:
*/1 * * * * /opt/lampp/htdocs/demon monitor >> /tmp/crontab/monitor.log#查看 /tmp/crontab/monitor.log 为空$ ll -sh0 -rwxrwxrwx 1 root root 0 8月 11 07:58 monitor.log#查看crontab日志,正常执行了Aug 11 07:37:01 iZ25v3bf76fZ CROND[1914]: (root) CMD (/opt/lampp/htdocs/demon monitor >> /tmp/crontab/monitor.log)Aug 11 07:37:01 iZ25v3bf76fZ CROND[1923]: (root) CMD (/opt/lampp/htdocs/demon monitor >> /tmp/crontab/monitor.log)#单独直接执行程序正常$ /opt/lampp/htdocs/demon monitor >> /tmp/crontab/monitor.log$ ll -sh4.0K -rwxrwxrwx 1 root root 1.9K 8月 11 08:00 monitor.log
crontab 环境变量中没有 PHP 执行路径导致失败。
计划任务修改为如下,添加 PHP 执行路径即可
*/1 * * * * /bin/php /opt/lampp/htdocs/demon monitor >> /tmp/crontab/monitor.log
共 0 条留言