文档中心 > 云服务器 ECS

云服务器 ECS Linux Crontab 执行 PHP 程序失败

更新时间: 访问次数:1557

问题现象


云服务器 ECS Linux Crontab 执行 PHP  程序失败。例如:

  
  
  1. */1 * * * * /opt/lampp/htdocs/demon monitor >> /tmp/crontab/monitor.log
  2. #查看 /tmp/crontab/monitor.log 为空
  3. $ ll -sh
  4. 0 -rwxrwxrwx 1 root root 0 8 11 07:58 monitor.log
  5. #查看crontab日志,正常执行了
  6. Aug 11 07:37:01 iZ25v3bf76fZ CROND[1914]: (root) CMD (/opt/lampp/htdocs/demon monitor >> /tmp/crontab/monitor.log)
  7. Aug 11 07:37:01 iZ25v3bf76fZ CROND[1923]: (root) CMD (/opt/lampp/htdocs/demon monitor >> /tmp/crontab/monitor.log)
  8. #单独直接执行程序正常
  9. $ /opt/lampp/htdocs/demon monitor >> /tmp/crontab/monitor.log
  10. $ ll -sh
  11. 4.0K -rwxrwxrwx 1 root root 1.9K 8 11 08:00 monitor.log

问题原因


crontab 环境变量中没有 PHP 执行路径导致失败。

解决办法


计划任务修改为如下,添加 PHP 执行路径即可

  
  
  1. */1 * * * * /bin/php /opt/lampp/htdocs/demon monitor >> /tmp/crontab/monitor.log

 

如果问题还未能解决,您可以到阿里云社区进行免费咨询,或联系云市场商家寻求帮助

FAQ

关于此文档暂时还没有FAQ
返回
顶部