On 09/12/2024 15:30, Greg Wooledge wrote:
On Mon, Dec 09, 2024 at 15:59:38 +0100, to...@tuxteam.de wrote:
On Mon, Dec 09, 2024 at 03:24:06PM +0100, Roger Price wrote:
I added lines to /etc/crontab such as

  # Watch over the NUT heartbeat at 0803 hr every day
  3    8    * * *  nut    /usr/local/bin/heartbeat-watcher.sh > /dev/null 2>&1
OK.  You have the correct format here.  Unfortunately, you've redirected
all the output and errors to /dev/null, so you won't know if it breaks,
or why.

A helpful tool here might be "cronic" (in the "cronic" package). "cronic" will swallow the output of the command it runs UNLESS that command exits with an error code.

So one would write:

3 8 * * * cronic /usr/local/bin/hearbeat-watcher.sh

and let's imagine the shell script does "echo Everything's okay ; exit 0" once a day, then you don't get too many emails. But when it fails (echo Everything's not okay ; exit 1), then you DO get an email.

Attachment: OpenPGP_signature.asc
Description: OpenPGP digital signature

Reply via email to