【问题标题】:Cron job with CodeIgniter using wget使用 wget 使用 CodeIgniter 进行 Cron 作业
【发布时间】:2015-08-31 12:44:36
【问题描述】:

我对设置 cron 作业很陌生。到目前为止,我所做的是使用以下脚本将其设置为每 5 分钟运行一次:

*/5 * * * * wget -q localhost:8888/example/index.php/controller/function

当我从命令行只运行 wget 部分时,它运行良好。但是在 crontab 中,虽然日志显示它每 5 分钟运行一次,但什么也没发生。我错过了一些简单的事情吗?任何帮助表示赞赏!

谢谢!

【问题讨论】:

  • wget 是否在任何 shell cron 使用的 $path 中?检查该帐户的邮件以获取 cron 日志。
  • 请原谅我对此一无所知,但是我如何确定 cron 正在使用哪个 shell?
  • 您可以尝试添加--output-file=logfile 看看发生了什么
  • 您可以使用 SHELL=bash 或 crontab 中的任何内容强制执行特定的 shell。然后确保 wget 在该 shell 的路径中可用。否则只需给出一个绝对的 /usr/bin/wget 路径。
  • @MarcB 成功了。如果你把它作为答案,我会接受它。感谢您的帮助!

标签: php codeigniter cron crontab wget


【解决方案1】:

您可以强制使用特定的外壳

SHELL=bash
*/5 * etc...

或 crontab 中的任何内容。然后确保 wget 在该 shell 的路径中可用。

否则只给出一个绝对的 /usr/bin/wget 路径。

*/5 * * * * /usr/bin/wget etc...

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-02-10
    • 1970-01-01
    • 2017-06-25
    • 1970-01-01
    • 2018-04-03
    • 2013-03-05
    • 1970-01-01
    相关资源
    最近更新 更多