doudui6756 2013-09-09 16:06
浏览 115
已采纳

设置Crontab以在CentOS中执行PHP脚本

I have searched hell and high water for a solution to a problem I'm having in CentOS. I'm trying to set up a cron job that executes a PHP script. I was able to get this working using wget, but now that we are going into production, I need to find a way to do this whilst being more secure, as the cron job itself works with sensitive data.

The error that I'm getting is: -bash: php: command not found.

Now I've looked around and I've seen people having the same problem, but nothing has been able to help me get this working.

For reference, here is what the working crontab looked like using the wget command.

* * * * * wget http://www.domain.com/cron_script.php

This is working fine, but I need to translate this into executing via PHP, rather than making an HTTP request to get the job done.

Let me know if I left anything out.

  • 写回答

1条回答 默认 最新

  • doupin5667 2013-09-09 16:10
    关注

    Cron doesn't have it's PATH set. The easiest thing is to change the php command to the full path of the php binary.

    /usr/bin/php /path/to/yourscript.php

    I'm fairly certain that's the path in CentOS but you can know for sure by doing which php on the command line and it will tell you.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料