cron 作业似乎超时了

发布于 2024-07-22 06:53:19 字数 449 浏览 7 评论 0原文

在 root 的 crontab 中设置以下 cronjob:(centos 5.x)

2 * * * * /usr/bin/curl --basic --user 'user:pass' http://localhost/cron/do_some_action > /var/www/app/cronlog.log

调用实际命令按预期工作,但是当 cronjob 运行时,它总是超时。 我使用了 set_time_limit() 和相关的 php.ini 设置来确保 PHP 不会死掉,并且 /var/log/cron 对我来说看起来很正常:

6 月 4 日 10:02:01 foobar crond[12138]: (root) CMD ([snip])

关于为什么 cronjob 会死掉有什么想法吗?

Have the following cronjob set up in root's crontab: (centos 5.x)

2 * * * * /usr/bin/curl --basic --user 'user:pass' http://localhost/cron/do_some_action > /var/www/app/cronlog.log

Invoking the actual command works as expected, however when the cronjob runs, it always times out. I've used set_time_limit() and related php.ini settings to ensure it's not PHP dying, and /var/log/cron looks normal to me:

Jun 4 10:02:01 foobar crond[12138]: (root) CMD ([snip])

Any ideas about why the cronjob would be dying?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

翻了热茶 2024-07-29 06:53:19

我想通了 -curl 的进度统计:

(100 65622    0 65622    0     0   1039      0 --:--:--  0:01:03 --:--:--  1927)

由于某种原因被写入 stderr -在命令末尾添加 2>&1 修复了它:

2 * * * * /usr/bin/curl --basic --user 'user:pass' http://localhost/cron/do_some_action > /var/www/app/cronlog.log 2>&1

感谢大家的所有见解!

I figured it out - curl's progress stats:

(100 65622    0 65622    0     0   1039      0 --:--:--  0:01:03 --:--:--  1927)

were being written to stderr for some reason - adding 2>&1 at the end of the command fixed it:

2 * * * * /usr/bin/curl --basic --user 'user:pass' http://localhost/cron/do_some_action > /var/www/app/cronlog.log 2>&1

Thanks to everyone for all the insight!

汐鸠 2024-07-29 06:53:19

添加用户

02 * * * * root /usr/bin/curl --basic --user 'user:pass' http: //localhost/not/porn > /var/www/app/filethatrootcanwriteto.log

add a user

02 * * * * root /usr/bin/curl --basic --user 'user:pass' http://localhost/not/porn > /var/www/app/filethatrootcanwriteto.log

粉红×色少女 2024-07-29 06:53:19

可以有 2 个 php.ini 文件,一个用于 apache,一个用于 CLI。

locate php.ini 应该可以找到两者,我建议您先检查那里。

There can be 2 php.ini files, one for apache and one for CLI.

locate php.ini should find both, I'd suggest you check there first.

甜味拾荒者 2024-07-29 06:53:19

这也可以通过使用 ob_start() 和 ob_end_flush() 缓冲 PHP 输出来避免curl 过早返回状态。

This can also be avoided by buffering your PHP output using ob_start() and ob_end_flush() to prevent curl from returning status prematurely.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文