What is heartbeat monitoring? Dead man's switches for jobs, explained
On this page
Heartbeat monitoring is a way to watch something that runs on a schedule by having it check in each time it runs. If a check-in doesn't arrive when it should, the monitor alerts you.
It's built for the failure that ordinary error alerts can't see: the job that didn't run at all. Nothing crashed, so nothing reported a crash. The only sign is silence, and a heartbeat monitor is something that notices silence.
How it works
You tell the monitor two things: how often the job runs, and how late it can be. The job sends a small HTTP request, the check-in or "ping", each time it runs.
- Schedule: a fixed interval ("every hour") or a cron expression ("
0 9 * * *", every day at 09:00) in a timezone. - Grace period: how much lateness is normal. Jobs start a few seconds late, take a variable time, or queue behind others.
- Deadline: the next expected time plus the grace period. If no check-in has arrived by then, the monitor alerts.
A worked example. A report runs daily at 09:00 with a 5-minute grace period:
| Time | What happens |
|---|---|
| Mon 09:00:40 | The job finishes and checks in. Next expected: Tue 09:00. Deadline: Tue 09:05:00 |
| Tue 09:00 | The job doesn't run (the server rebooted overnight and cron didn't come back) |
| Tue 09:05:00 | The deadline passes with no check-in |
| Tue, first check after 09:05:00 | The monitor sends a missed-run alert |
How soon "first check after" is depends on how often the monitor looks. Stallbell checks every minute, so the alert goes out within about a minute of the deadline.
What it catches, and what it doesn't
A basic heartbeat catches anything that stops the check-in from arriving:
- the scheduler stopped (cron not running, a workflow switched off)
- the server, container or VM is down
- the job was deleted or its schedule was changed by mistake
- the job crashed before it reached the check-in line
- the job hangs and never reaches it
It doesn't catch, on its own:
- A job that runs and does the wrong thing. If it checks in, the heartbeat is happy.
- A failure that still checks in. A plain "I ran" ping after a failed step looks like success.
- A hang, quickly. A hung job only shows up when the next deadline passes, which for a daily job is a day later.
That's why heartbeat monitors usually accept more than one signal.
Start, finish and fail signals
Most heartbeat services, Stallbell included, let a job say more than "I ran":
- Finish with a result. Send success or failure, often as the exit code. A failure can alert straight away, instead of waiting for a deadline.
- Start. Send a start ping when the run begins. If no finish follows within a maximum duration, the monitor knows the run is stuck, without waiting for the next scheduled run.
- Run IDs. Send the same ID on the start and the finish, so the monitor can join them into one run and measure how long it took, even when runs overlap.
With Stallbell, all of these are URL paths on the same ping URL:
curl -fsS -m 10 'https://stallbell.com/p/TOKEN/start?run_id=r42' curl -fsS -m 10 'https://stallbell.com/p/TOKEN/0?run_id=r42' # 0 is success, 1 to 255 is failure
Terms you'll see
| Term | Meaning |
|---|---|
| Heartbeat, check-in, ping | the request the job sends when it runs |
| Dead man's switch | the same idea, named after a switch that triggers when its holder stops pressing it. The alert fires on the absence of a signal |
| Grace period | allowed lateness before a missed run is declared |
| Deadline | expected time plus grace period |
| Max duration (Stallbell: "Stuck after") | how long a started run can go without finishing before it counts as stuck |
| Missed run | no check-in by the deadline |
AI agents and automations: checking the result
Scheduled AI agents add a failure that classic heartbeats don't see: the run finishes, checks in as a success, and its answer is empty or isn't valid JSON. Some monitors let the finish ping carry the output so it can be checked too. In Stallbell, the finish ping can include an output field, and you get an Empty output alert when it's blank, only whitespace, missing a required phrase, or not valid JSON.
Where heartbeat monitoring fits
- Cron jobs and scripts: backups, reports, cleanups. See how to monitor cron jobs.
- Workflow tools: scheduled n8n workflows. See how to monitor n8n workflows.
- AI agents on a timer: see how to monitor AI agents that run on a schedule.
FAQ
Is heartbeat monitoring the same as uptime monitoring? No. Uptime monitoring calls your service from outside and checks that it answers. Heartbeat monitoring waits for your job to call in. A website needs the first; a nightly job that serves nothing needs the second.
What grace period should I use? Enough to cover a normal late start and a normal run time. Start with a few minutes for short jobs, and look at real check-in times after a week.
What happens if the monitoring service is down when my job pings? Write the ping so its failure can't fail the job: a short timeout and no effect on the job's exit code. A missed ping then shows up as a missed run, which is a false alarm rather than a broken job.
Does the job need an SDK? No. A check-in is a plain HTTP request, so curl or any HTTP client is enough.
Try it on one job
Pick one scheduled job you'd want to know about if it stopped, and give it a heartbeat.
Related: How to monitor cron jobs · Why cron jobs fail silently · Detect stuck jobs · Alert on empty LLM output