Monitor a Cron Job With a Heartbeat URL
How to monitor a cron job with a heartbeat URL: the period and the grace, the ping with && curl, the states New, Up, Late and Down, and alerts to a webhook.

A nightly backup that crashes can send an error. A backup that never starts, because the server was off or the schedule was lost, sends nothing, and nobody notices. Cron job monitoring with a heartbeat catches both: the job pings a URL when it succeeds, and a monitor raises an alert when the ping does not arrive on time. The Cron Job Heartbeat Monitor provides the URL and the alert, without an account.
How a heartbeat works
The idea is a dead man's switch. Instead of waiting for the job to report a failure, the monitor expects a regular sign of life. The job calls the monitor's URL each time that it finishes successfully. If the call is missing when it should have arrived, something is wrong, and the reason does not matter for the alert: the job failed, did not run, ran on the wrong day or the whole machine is gone.
This is why a heartbeat is more reliable than an error message from the job. A script cannot report its own death. A silent monitor on the outside can.
Two settings define the expectation. The period says how often the ping must arrive, for example every day. The grace says how much extra time to allow before the monitor calls it a problem, because jobs take a little longer on some days.
Create monitor: period, grace and webhook
- Open the Cron Job Heartbeat Monitor.
- Enter a Job name, for example Nightly backup.
- Set Expected every (1 minute to 7 days) and the Grace period (1 minute to 1 day). For a backup at 02:00 every night, use 1 day and a grace of 30 minutes.
- Optionally enter a Webhook URL, which receives a JSON POST for each alert.
- Press Create monitor.
If you are not sure of the schedule expression of your job, the Cron Expression Generator helps, as in Cron Expression for Every Weekday at 9:30.

After you create the monitor, you get two things: the ping URL that your job calls, and a private dashboard link. Copy both. The ping URL goes into the job, and the dashboard link is your only way back to the monitor.
Add the ping to the job
Add a call to the ping URL at the end of the job, after the work has succeeded. With curl, a single line does it:
backup.sh && curl -fsS -m 10 --retry 3 <ping URL>
The && is the important part. The shell runs the second command only if the first one succeeded, so the ping is sent only after a successful backup. If backup.sh fails, no ping is sent, and the monitor notices the silence.
The dashboard shows two more calls. Add /fail to the ping URL and send a short message in the body, up to 1 KB, to report a failure with its reason, and add /start at the beginning of a run so that the monitor can show how long the run took.
The curl options keep the ping reliable and quiet. -f makes curl fail on an HTTP error, -s hides the progress output, -S still shows an error message if there is one, -m 10 limits the whole call to 10 seconds, and --retry 3 repeats the call up to three times if it fails. The options are explained in the curl manual page.
Test it once by running the line by hand, and check that the state of the monitor changes.
States: New, Up, Late, Down
A monitor shows one of four states.
- New: the monitor was created, and no ping has arrived yet.
- Up: the last ping arrived on time.
- Late: the expected ping is overdue, but the grace has not run out.
- Down: the grace has run out, and the ping did not come.
For the nightly backup of the example, a ping at 02:00 sets the state to Up.

If the next ping does not arrive, the monitor turns Late when the expected time has passed, and Down when the grace of 30 minutes is over. You get one alert when the state becomes Down, and one more when a ping arrives again and the state returns to Up, the recovered alert. There is no stream of repeated alerts while the job stays down.
The Late state is a warning without an alert. A backup that sometimes finishes a few minutes late stays out of the alert list unless it passes the grace.
Keep the dashboard link
The service needs no account, so there is no password to reset and no recovery. The private dashboard link is the only key to the monitor. Store it in a password manager or in your documentation. If you lose it, you cannot open the dashboard again, and you would have to create a new monitor and change the ping URL in the job.
The alerts are sent as a JSON POST to the webhook URL that you entered, and the monitor retries a failed delivery 3 times. To see what an alert looks like before you connect it to your chat or ticket system, use the Webhook Test URL (Request Catcher) as the webhook. A caught alert has a body such as the monitor name Nightly backup and the event down.

Test a Webhook Without a Server shows how to read it. When your endpoint is ready, replace the test URL with the real one. For alerts that carry the reason of a failure, call the /fail address, as described above.
Try it
Open the Cron Job Heartbeat Monitor, create a monitor with the period and the grace of your job, and store the dashboard link. Add the ping to the end of the job with &&, run it once by hand, and check that the state is Up.