How to monitor cron jobs and backups with a heartbeat
Updated October 26, 2026 · 6 min read
A website that's down is obvious. A nightly backup that stopped running three weeks ago isn't, because nothing visible breaks. You find out the day you need the backup. Scheduled jobs fail quietly, and an ordinary uptime check can't see them, because there's nothing to request.
A heartbeat monitor turns this round. Instead of you checking the job, the job reports in each time it runs. If a report doesn't arrive on time, you're alerted.
How a heartbeat works
- You create a heartbeat and say how often the job should run and how late a report may be.
- You get a private web address, called the ping address.
- At the end of the job, you make a request to that address.
- If no request arrives by the time it's due plus the allowance, the heartbeat is marked down and you're alerted. When the next report arrives, it's marked up again and you're told.
Site Monitors offers heartbeat monitors from the Starter plan. Give it a name like "Nightly backup", choose how often it runs (from every 5 minutes to every 7 days) and how late a report may be (from 1 minute to 6 hours).
Add it to a cron job
Add one request at the end of the job, joined with && so it only runs if the job succeeded:
0 2 * * * /opt/scripts/backup.sh && curl -fsS -m 10 --retry 3 https://example.com/api/ping/YOUR-CODE > /dev/nullReplace the address with your heartbeat's own. What the options do:
&&means the request is only sent whenbackup.shfinishes without an error. If the backup fails, no report is sent, and you're alerted once the allowance runs out.-fmakescurltreat an error response as a failure,-sShides progress but keeps errors,-m 10gives up after 10 seconds so a network problem can't hang the job, and--retry 3tries again if it fails.
In a shell script, put the request on the last line. For a systemd timer, use ExecStartPost= in the service, or add the request to the end of the script it runs. Any tool that can call a web address, such as a backup program's "notify URL" setting, works too.
Pick sensible numbers
- Match the schedule. A job that runs once a day should be "every 1 day", not "every hour".
- Leave some room. Give it a bit more than the job's usual run time, so a slow night doesn't cause a false alarm.
- Think about time zones. Cron runs in the server's time zone. The heartbeat only cares about the gaps between reports, so as long as the gap matches, the zone doesn't matter.
Test it before you rely on it
- Make a heartbeat with the shortest schedule, every 5 minutes with 1 minute to spare.
- Run the
curlcommand by hand and watch it show as on time. - Stop sending reports. After about 6 minutes it goes overdue and you're alerted.
- Send one again, and check it returns to up. Then set the real schedule.
What to monitor this way
- Backups, especially off-site and database dumps.
- Scheduled imports, syncs and report emails.
- Renewal and billing runs.
- Cleanup jobs that stop a disk filling up.
Keep the address private. Anyone who has it can send reports for that heartbeat, and if it leaks, delete the heartbeat and make a new one.