How to monitor a cron job

Cron jobs fail silently. Heartbeat monitoring turns a missing run into an alert. Setup for cron, systemd timers, Kubernetes and GitHub Actions.

The problem with cron is that nothing happens when it fails. No page goes down, no error is shown; the backup just is not there when you need it.

The heartbeat pattern

Give each job a unique URL. The job calls it on success. A monitor expects the call every N hours; if it is late, you get an alert.

Cron

0 3 * * * /usr/local/bin/backup.sh && curl -fsS -m 10 https://hb.uptimepush.com/p/TOKEN

systemd timers

Add ExecStartPost=/usr/bin/curl -fsS https://hb.uptimepush.com/p/TOKEN to the service unit.

Kubernetes CronJob

Append the curl call to the container command with && so it only runs on success.

GitHub Actions

Add a final step that curls the URL, with the token stored as a secret.

Grace periods

Set a grace period slightly longer than the job's longest normal run, so a slow night does not page you.

Your website doesn't sleep. Now you can.

Start monitoring in minutes. Your first 10 monitors are on us.

Start free – no card ↗