Cron output options when using curl

cron

when running a cron job like this:

curl http://example.com/cronjob.php

The output sent to mail contains this:

% 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

I find this totally useless and would prefer just the code output. Is there any way to disable this?

I don't get this if the cronjob is run like below:

php /path/to/the/phpfile.php

But right now, I do not have an option but to use curl.

Best Answer

Searching in man curl: ...

  -s/--silent
          Silent mode. Don’t show progress meter or error messages.
          Makes Curl mute.

So curl -s http://example.com/cronjob.php will do the trick.

You may want to use the following option as well:

   -S/--show-error
          When used with -s it makes curl show error message if it fails.

Hope it helps.