【问题标题】:How to create a cron job to run script from web?如何创建一个 cron 作业以从 Web 运行脚本?
【发布时间】:2013-04-29 16:01:47
【问题描述】:

我在服务器 www.domain.com 中使用 CENTOS 创建了一个 cron 作业:

*/10 * * * * http://www.anotherdomain.com/cron/task.php

但它的回归:

/bin/sh: http://www.anotherdomain.com/cron/task.php: No such file or directory

如何让它发挥作用?

【问题讨论】:

  • 使用 curl 或 wget 调用远程页面
  • @Dagon 你应该把它放在答案中,因为它是正确的解决方案。

标签: php cron centos


【解决方案1】:

如果您更喜欢 curl 并且这里是 reasons you might,您的 cronjob 应该是:

*/10 * * * * curl -s http://www.anotherdomain.com/cron/task.php -o /dev/null

s 禁止 curl 的任何状态输出,并且 -o 将其重定向到后面的文件 -- 在本例中为 /dev/null

【讨论】:

    【解决方案2】:
     */10 * * * *  wget -q -t 5 --delete-after http://www.anotherdomain.com/cron/task.php
    

    q = 安静

    t = 重试以防网络问题(在这种情况下为 5)

    delete-after = 我们实际上并不想要远程页面的输出

    【讨论】:

      猜你喜欢
      • 2012-08-17
      • 2011-11-07
      • 2012-08-06
      • 2011-03-12
      • 2019-02-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多