Heartbeat monitoring for cron jobs
Get alerted when a scheduled job, backup, or worker stops reporting.
2 min readThis guide covers Premium features. Premium is in early access and cannot be bought yet.
How a heartbeat works
A heartbeat monitor has no address to check. Instead, your job requests the monitor’s secret ping URL each time it finishes. The monitor goes down when no ping arrives within the period you choose plus a grace time, and recovers on the next ping.
The grace time replaces the 30-second confirmation of other monitors: neither a missed ping nor a recovery waits for a second look. A ping that reports a failure takes the monitor down at once.
Add a heartbeat monitor
- Open Monitors, select Add monitor, and choose Heartbeat (cron job) as the monitor type.
- Set Expected every to how often the job runs, from 1 minute to 30 days, and a grace time for late or long runs, from 1 minute to 7 days.
- Save the monitor and copy its ping URL from the dialog. It is shown once: Cheapmonit keeps only a hash of it.
Heartbeat monitors are part of Premium and count toward the monitor limit. The first deadline counts from when the monitor is added.
Ping from your job
Request the URL with GET, HEAD, or POST when the job succeeds, and add /fail to the URL when it fails. A request body is not read. Each monitor takes up to 10 pings a minute; more are answered 429 and not saved.
0 3 * * * /usr/local/bin/backup.sh && curl -fsS -m 10 --retry 3 https://cheapmonit.com/api/heartbeat/<token>/usr/local/bin/backup.sh || curl -fsS -m 10 --retry 3 https://cheapmonit.com/api/heartbeat/<token>/failReplace a lost or leaked URL
Anyone who holds the ping URL can report for the job, so keep it out of public code and chat. If it is lost or shared, open the monitor and select Replace ping URL: the old URL stops working at once, and the new one is shown once.
Pausing a heartbeat monitor stops watching for pings; resuming it, or the end of a maintenance window, starts a full period and grace time again. Changing the period moves the current deadline by the difference. After a downgrade from Premium, existing heartbeat monitors keep taking pings and alerting.