[GH-ISSUE #37] Cron example should suppress stdout #18

Closed
opened 2026-02-25 23:40:47 +03:00 by kerem · 4 comments
Owner

Originally created by @mgedmin on GitHub (Jan 24, 2016).
Original GitHub issue: https://github.com/healthchecks/healthchecks/issues/37

https://healthchecks.io/docs/ recommends

# m h dom mon dow   command
  8 6 *   *   *     /home/user/tasks/backup_all.sh && curl https://hchk.io/53770999-ffd4-4c9b-a62e-013e62bb3368

But curl prints the response string (OK) to stdout, which will cause cron to send an email. I suggest that you change the example to redirect the output to /dev/null.

Originally created by @mgedmin on GitHub (Jan 24, 2016). Original GitHub issue: https://github.com/healthchecks/healthchecks/issues/37 https://healthchecks.io/docs/ recommends ``` # m h dom mon dow command 8 6 * * * /home/user/tasks/backup_all.sh && curl https://hchk.io/53770999-ffd4-4c9b-a62e-013e62bb3368 ``` But curl prints the response string (`OK`) to stdout, which will cause cron to send an email. I suggest that you change the example to redirect the output to `/dev/null`.
kerem closed this issue 2026-02-25 23:40:47 +03:00
Author
Owner

@mgedmin commented on GitHub (Jan 24, 2016):

Oh, and also pass the appropriate option to suppress the progress bar, otherwise you get emails like this:

/etc/cron.hourly/mg-healthchecks-dot-io:
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
^M  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0^M100     2  100     2    0     0      9      0 --:--:-- --:--:--
--:--:--     9
<!-- gh-comment-id:174290301 --> @mgedmin commented on GitHub (Jan 24, 2016): Oh, and also pass the appropriate option to suppress the progress bar, otherwise you get emails like this: ``` /etc/cron.hourly/mg-healthchecks-dot-io: % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed ^M 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0^M100 2 100 2 0 0 9 0 --:--:-- --:--:-- --:--:-- 9 ```
Author
Owner

@cuu508 commented on GitHub (Jan 24, 2016):

So a better curl invocation would be

my-cron-script.sh && curl -fsS https://hchk.io/452461b8-8949-4bcf-9f93-9fdbc661742f > /dev/null

-f makes curl treat non-200 responses as errors
-s Silent mode. Don’t show progress meter or error messages. Makes Curl mute.
-S When used with -s it makes curl show error message if it fails.

Or maybe use long options to make it self-documenting:

my-cron-script.sh && curl --fail --silent --show-error --output /dev/null https://hchk.io/452461b8-8949-4bcf-9f93-9fdbc661742f
<!-- gh-comment-id:174313435 --> @cuu508 commented on GitHub (Jan 24, 2016): So a better curl invocation would be ``` my-cron-script.sh && curl -fsS https://hchk.io/452461b8-8949-4bcf-9f93-9fdbc661742f > /dev/null ``` -f makes curl treat non-200 responses as errors -s Silent mode. Don’t show progress meter or error messages. Makes Curl mute. -S When used with -s it makes curl show error message if it fails. Or maybe use long options to make it self-documenting: ``` my-cron-script.sh && curl --fail --silent --show-error --output /dev/null https://hchk.io/452461b8-8949-4bcf-9f93-9fdbc661742f ```
Author
Owner

@mgedmin commented on GitHub (Jan 24, 2016):

Yes, the -fsS line sounds good.

Using the long form would make the snippet wider, which would make it less convenient to copy and paste. If anyone's curious, they can run curl --help or man curl and look up what -f, -s and -S mean.

<!-- gh-comment-id:174314864 --> @mgedmin commented on GitHub (Jan 24, 2016): Yes, the `-fsS` line sounds good. Using the long form would make the snippet wider, which would make it less convenient to copy and paste. If anyone's curious, they can run `curl --help` or `man curl` and look up what `-f`, `-s` and `-S` mean.
Author
Owner

@mgedmin commented on GitHub (Jan 29, 2016):

It may be also useful to pass --retry 10 or something like that to curl. I've already had two spurious "host is down" notifications due to my hourly cron script failing with

curl: (6) Could not resolve host: hchk.io

I'm hoping the --retry will help; time will tell if I'm right.

<!-- gh-comment-id:176633991 --> @mgedmin commented on GitHub (Jan 29, 2016): It may be also useful to pass `--retry 10` or something like that to curl. I've already had two spurious "host is down" notifications due to my hourly cron script failing with > curl: (6) Could not resolve host: hchk.io I'm hoping the `--retry` will help; time will tell if I'm right.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/healthchecks#18
No description provided.