【问题标题】:lynx cronjob called but HTTP request not sentlynx cronjob 已调用,但未发送 HTTP 请求
【发布时间】:2014-05-22 10:42:33
【问题描述】:

我使用以下命令每 30 分钟从我的共享主机运行一次 cronjob 到我的另一个 ec2 服务器:-

0,30 * * * * /usr/bin/lynx http://qwerty.com/crons/myCron.php

根据我从 Cron 守护程序收到的电子邮件,cron 作业确实每 30 分钟运行一次。但是有时似乎只调用了 PHP 文件。我注意到只有在我收到的 Cron Daemon 电子邮件中发送 HTTP 请求时它才会成功。

示例如下:-

不成功的尝试

 Your Terminal type is unknown!

 Enter a terminal type: [vt100] 
TERMINAL TYPE IS SET TO vt100
(B)0[1;24r[m[?7h[?1h=[H[J[21B[0;7mGetting http://qwerty.com/crons/myCron.php[m
[0;7mLooking up qwerty.com[m[K
[0;7mMaking HTTP connection to qwerty.com[m

[24;1H
[?1l>

成功尝试

 Your Terminal type is unknown!

 Enter a terminal type: [vt100] 
TERMINAL TYPE IS SET TO vt100
(B)0[1;24r[m[?7h[?1h=[H[J[21B[0;7mGetting http://qwerty.com/crons/myCron.php[m
[0;7mLooking up qwerty.com[m[K
[0;7mMaking HTTP connection to qwerty.com[m
[0;7mSending HTTP request.[m             [22;22H
[0;7mHTTP request sent; waiting for response.[m

[24;1H
[?1l>

如何确保每次 cron 守护程序运行时都发送 HTTP 请求?

【问题讨论】:

    标签: php linux cron lynx


    【解决方案1】:

    您可以尝试强制转储,但这也会转储页面中的所有 HTML。可能不适用。 -dump 将默认文档或在命令行中指定的格式化输出转储到标准输出。在 UNIX 下,这可以通过以下方式使用:

    lynx -dump http://qwerty.com/crons/myCron.php

    或者

    /usr/bin/lynx -mime_header -dump http://qwerty.com/crons/myCron.php
    

    或者,您可以尝试 wget 多次尝试以确保完全响应..

    /usr/bin/wget −r −−tries=10 http://qwerty.com/crons/myCron.php
    

    你可以再次尝试 cURL:

    curl http://qwerty.com/crons/myCron.php
    

    这些选项中的任何一个对您来说是可行的吗?

    【讨论】:

    • 您好,感谢您回来。将尝试转储 mime_header 以查看是否可以获得更多信息,并查看 curl 是否对我可用。
    • 虽然不太热衷于使用 wget,因为我只希望 cron 每 30 分钟运行一次。
    • @user1258600 你仍然可以使用 wget.. cron 控制命令何时发生。只需删除 r 并尝试参数
    • 监测了几天,curl似乎解决了我的问题。非常感谢!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-08-02
    • 1970-01-01
    • 1970-01-01
    • 2017-06-01
    • 2018-05-14
    相关资源
    最近更新 更多