Heartbeat monitoring is a monitoring method in which a job, script or service sends a regular signal to a monitoring system, and the system raises an alert when that signal does not arrive within the expected interval. In monitoring & logs for servers, it detects silent failures: the backup that never started, the cron job that was deleted, or the worker that hung without writing a single error.
The approach is also called cron monitoring or dead man’s switch monitoring, because it watches for the absence of an event rather than the presence of an error. That inversion makes it a necessary complement to log analysis and health checks, which can only report problems that some component actually notices and records.
How heartbeat monitoring detects missing signals
Heartbeat monitoring works by pairing an expected schedule with a timer. The operator creates a check with a period, such as every hour, and a grace period, such as ten minutes. The monitored job sends a ping, usually an HTTP request to a unique URL, each time it runs. Every ping resets the timer, and if the timer expires, the check changes to a failed state and notifies the team.
Many implementations accept several signal types to describe a run more precisely. A start signal marks the beginning of a job, a success signal marks its end, and a failure signal reports a known error. With start and end signals, the monitor can also measure job duration and alert when a task runs much longer than usual, which often indicates a hang or a growing data set.
The model is push-based: the monitored component contacts the monitor, not the other way around. This lets heartbeat checks watch jobs on servers behind firewalls or NAT, on laptops and on short-lived containers that no external probe could reach at the right moment.
Key parameters of a heartbeat check
A heartbeat check is defined by a few parameters, and choosing them carefully decides whether alerts are useful or noisy. The table summarizes them and their typical values.
| Parameter | Meaning | Typical value |
|---|---|---|
| Period | Expected interval between pings | From 1 minute to 1 day |
| Cron expression | Exact schedule instead of a fixed period | For example 0 2 * * * for 02:00 daily |
| Grace period | Tolerance before alerting | 10 to 50 percent of the period |
| Time zone | Zone used to read the schedule | Must match the server schedule |
| Maximum duration | Allowed time between start and end | Based on historical run times |
| Notification channels | Where alerts are sent | Email, chat, SMS or on-call tools |
The grace period deserves the most attention. A value that is too short produces false alarms whenever a job starts a little late or the network delays the ping. A value that is too long delays detection, which matters for time-critical jobs such as payment exports or certificate renewals.
Heartbeat monitoring compared with related methods
Heartbeat monitoring answers a different question from other monitoring methods: did the expected thing happen on time. The comparison below shows where it fits beside its neighbors in the monitoring toolset.
| Method | Direction | Question answered | Typical target |
|---|---|---|---|
| Heartbeat monitoring | Job pushes to monitor | Did the task run on schedule | Cron jobs, backups, queues |
| Uptime monitoring | Monitor polls from outside | Is the service reachable | Websites and public APIs |
| Health check | Load balancer or orchestrator polls | Is this instance ready | Containers and pool members |
| Log-based alerting | Logs flow to an analyzer | Did an error get recorded | Application and error logs |
| Metrics alerting | Agent reports measurements | Is a value outside its range | CPU, disk and latency |
The methods overlap but do not replace one another. A website can pass every uptime check while its nightly database export has been failing for weeks. Conversely, heartbeat monitoring knows nothing about response time or user-facing errors, so a complete setup combines it with polling and log-based alerting.
Implementing heartbeat checks in practice
The simplest implementation adds one HTTP request at the end of a job, chained so that it runs only on success. On Linux, a crontab line can append a curl call after the main command using a logical AND, so the ping is skipped whenever the command exits with an error. Tools such as Uptime Kuma, Zabbix and dedicated cron monitoring services provide push endpoints for this purpose.
The right design depends on the type of workload. The following table maps common situations to a suitable heartbeat pattern.
| Workload | Recommended pattern | Reason |
|---|---|---|
| Nightly backup script | Start and success pings with maximum duration | Detects both missed and stuck runs |
| Frequent queue worker | Ping every few minutes from the main loop | Reveals a hung process quickly |
| Certificate renewal | Daily ping with a generous grace period | Failures matter days before expiry |
| Serverless scheduled function | Ping from the function after work completes | No host exists to monitor directly |
| Data pipeline step | Failure ping with exit code or log excerpt | Speeds up diagnosis of known errors |
Each check should have a clear owner and a runbook. An alert that reads only “backup missed” helps little at 03:00; an alert that names the server, the job, the last successful run and the first diagnostic step shortens recovery considerably.
Pitfalls and failure modes
Heartbeat monitoring is simple, which makes configuration mistakes easy to overlook. The most frequent problems are listed below.
- Pinging unconditionally. A ping sent even when the job fails reports false success; always tie the ping to the exit status.
- Time zone mismatch. A schedule read in UTC while the server runs in local time produces alerts at the wrong hour, especially around daylight saving changes.
- Monitor as a single point of failure. If the monitoring system itself stops, no alerts arrive; it should be watched from a second location.
- Leaked ping URLs. Anyone holding a check URL can send fake pings, so treat it like a credential.
- Success without verification. A job that exits successfully may still produce an empty backup; add content checks such as file size or record counts.
The last point is the most dangerous. A heartbeat proves that a job ran, not that it did the right thing, so critical tasks such as backups still need periodic restoration tests and output validation.
The short version
Heartbeat monitoring works like a daily check-in call from someone you care about. You do not need them to report every detail; you just expect the call at the usual time. If the phone stays silent, you know something has gone wrong and you go and look.
Computers do the same with their scheduled tasks. Each task sends a short message saying “I ran”, and if that message does not arrive on time, the monitoring system warns the people in charge before the missing work causes bigger trouble.
Where it makes a difference
A small e-commerce company runs a nightly database backup at 01:30 on its main server, followed by an upload to offsite storage. The team added a heartbeat check with a daily cron schedule, a 45-minute grace period and a maximum duration of 90 minutes, and the backup script sends start and success pings to the monitor.
Months later, a server migration copied every service but forgot the crontab entry. No errors appeared in any log, because nothing ran. At 02:15 the next morning the heartbeat check turned red and paged the on-call engineer, who restored the schedule the same day. Without the check, the company would have discovered the gap only when it needed a restore, potentially weeks of backups missing.