使用 curl 时的 cron 输出选项

cod*_*er_ 6 cron

运行这样的 cron 作业时:

卷曲http://example.com/cronjob.php

发送到邮件的输出包含以下内容:

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

 0    52    0    52    0     0     81      0 --:--:-- --:--:-- --:--:--    81
 0    52    0    52    0     0     31      0 --:--:--  0:00:01 --:--:--     0
 0    98    0    98    0     0     37      0 --:--:--  0:00:02 --:--:--    23
 0    98    0    98    0     0     27      0 --:--:--  0:00:03 --:--:--    15
 0    98    0    98    0     0     21      0 --:--:--  0:00:04 --:--:--    11
100   144    0   144    0     0     25      0 --:--:--  0:00:05 --:--:--    18
100   144    0   144    0     0     21      0 --:--:--  0:00:06 --:--:--    18
100   190    0   190    0     0     23      0 --:--:--  0:00:07 --:--:--    17
100   190    0   190    0     0     21      0 --:--:--  0:00:08 --:--:--    17
100   236    0   236    0     0     24      0 --:--:--  0:00:09 --:--:--    27
Run Code Online (Sandbox Code Playgroud)

我发现这完全没用,更喜欢代码输出。有什么办法可以禁用它吗?

如果 cronjob 运行如下,我不会得到这个:

php /path/to/the/phpfile.php

但是现在,我别无选择,只能使用 curl。

L.R*_*.R. 8

搜索man curl:...

  -s/--silent
          Silent mode. Don’t show progress meter or error messages.
          Makes Curl mute.
Run Code Online (Sandbox Code Playgroud)

所以curl -s http://example.com/cronjob.php会做的伎俩。

您可能还想使用以下选项:

   -S/--show-error
          When used with -s it makes curl show error message if it fails.
Run Code Online (Sandbox Code Playgroud)

希望能帮助到你。

  • 谢谢 - `curl -sS http://example.com/cronjob.php` 对我很有用。 (2认同)