【问题标题】:Curl shell php cron results卷曲外壳 php cron 结果
【发布时间】:2012-02-27 08:47:56
【问题描述】:

每次运行 cron 作业时,我都会在电子邮件中收到以下内容:

这是什么意思?有什么问题吗?为什么我会收到此消息?

% Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                               Dload  Upload   Total   Spent    Left  Speed

0     6    0     6    0     0     22      0 --:--:-- --:--:-- --:--:--    22
0     6    0     6    0     0     22      0 --:--:-- --:--:-- --:--:--     0

【问题讨论】:

  • 如果你真的说明了 cronjob 中的内容会很有帮助。
  • curl 用于从网络获取信息 - 我不确定它是否与 php 和 cron 有任何关系,除非您在 php 中编写了一个在 cron 中调度并使用 curl 的脚本: curl.haxx.se/docs/manpage.html 如果您发布从 crontab 运行的行并且如果它是对脚本的调用,那么它会很有帮助 - 然后也发布代码。
  • @Amber 和 alfasin,好点子,请参阅下面 cmets 中我在 crontab 中运行的行。

标签: php shell cron


【解决方案1】:

如果您通过命令行运行它,您可能需要将-s 传递给curl,告诉它保持静默并且不向终端输出进度信息。

同时传递-S(例如curl -s -S)以使其在遇到错误消息时显示错误消息,即使您已将其静音。

【讨论】:

  • 我的代码是/usr/bin/curl http://mydomain.com/cron/script.php 2>&1,我应该改成:/usr/bin/curl -s -S http://mydomain.com/cron/script.php 2>&1
  • 是的,Lucy - 这正是您想要更改的内容。
【解决方案2】:

使用参数运行,例如:curl --silent yourscript.php

-s, --silent

静音或安静模式。不要显示进度表或错误消息。使 Curl 静音。

-S, --show-error

当与 -s 一起使用时,如果 curl 失败,它会显示错误消息。

查看http://curl.haxx.se/docs/manpage.html 了解更多选项。

【讨论】:

  • 我的代码是/usr/bin/curl http://mydomain.com/cron/script.php 2>&1,我应该改成:/usr/bin/curl -s -S http://mydomain.com/cron/script.php 2>&1
猜你喜欢
  • 2013-07-27
  • 1970-01-01
  • 2018-06-07
  • 2015-08-30
  • 1970-01-01
  • 1970-01-01
  • 2019-09-19
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多