Skip to content

Cron monitoring examples: crontab, Docker

The principle is the same everywhere: make an HTTP request to the ping URL when the job succeeds (and, better, to /start at the beginning and /fail on failure). Replace <ping-key> with your check’s key. The -fsS -m 10 --retry 3 options are explained in the ping API.

The simplest: the ping is sent only if the script succeeds (&&).

crontab -e
0 2 * * * /usr/local/bin/backup.sh && curl -fsS -m 10 --retry 3 https://app.silencewatch.com/p/<ping-key>

To measure the duration and report failure explicitly, use a small wrapper script:

/usr/local/bin/backup-monitored.sh
#!/bin/sh
URL=https://app.silencewatch.com/p/<ping-key>
curl -fsS -m 10 --retry 3 "$URL/start"
/usr/local/bin/backup.sh
curl -fsS -m 10 --retry 3 "$URL/$?"

Write nothing: the Spring Boot starter discovers @Scheduled methods and Quartz jobs and sends the pings for you.