cron output options when using curl
5,929
Solution 1
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.
Solution 2
Have you tried:
curl --silent http://example.com/cronjob.php >>/path/to/output.log 2>&1
??
Related videos on Youtube
Author by
coder_
Updated on September 17, 2022Comments
-
coder_ about 1 year
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.
-
Dave James Miller about 11 yearsThank you -
curl -sS http://example.com/cronjob.php
worked great for me.