Cron heartbeat monitor

The backup that stopped in March because the disk filled up. The cron job that vanished when the server was rebuilt. Nothing errors when a job stops running, so nothing tells you. A heartbeat turns the check around: the job calls a URL when it finishes, and silence is the alarm.

Reading the schedule…

crontab

0 9 * * 1-5  /usr/local/bin/backup.sh && curl -fsS -m 10 --retry 5 -o /dev/null https://hooks.raqibo.com/ping/YOUR-TOKEN || curl -fsS -m 10 --retry 5 -o /dev/null https://hooks.raqibo.com/ping/YOUR-TOKEN/fail

Success pings the URL; a non-zero exit pings /fail, which is down at once. If the success ping cannot get through after five tries, the fail ping goes instead - either way the missing run does not go unnoticed.

How it works

Each heartbeat gets its own URL on hooks.raqibo.com. The job calls it when it succeeds, or calls the same URL ending in /fail when it does not. GET, POST and HEAD all count, and nothing in the request is read, so a one-line curl is all the integration there is.

Every ping restarts a clock: the next one is due a period later, plus the grace. When the deadline passes with no ping, an incident opens and you are told, by email or by a webhook to Slack, Discord or your own endpoint. It stays one incident however long the job is quiet, and the first ping that arrives closes it.

Why the period is the longest gap

A heartbeat cannot read your crontab, so it does not know the job is meant to skip the weekend. It only knows how long it has been since the last ping. Set the period to the job's usual interval and every planned silence longer than that becomes an alert, which is how heartbeats get muted in their first week. The planner above finds the longest silence the schedule allows, so the only alerts left are real.

Details

Time is ours, not the sender's: a ping counts when we receive it, so a server with a drifting clock cannot make a late job look punctual. One missed deadline is enough to open an incident, because unlike a website check there is no network path to blame for an absence. A paused heartbeat still answers its pings with 200, so the job does not start failing while you are working on it.

The URL is the credential: anyone who has it can report the job alive. It is never included in an alert, and replacing it takes one click.

Heartbeats need an account, because they keep running after you leave. Create one with an email address - no password, no card.