Heartbeat monitoring

Also known as: cron monitoring

On this page 7

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.

ParameterMeaningTypical value
PeriodExpected interval between pingsFrom 1 minute to 1 day
Cron expressionExact schedule instead of a fixed periodFor example 0 2 * * * for 02:00 daily
Grace periodTolerance before alerting10 to 50 percent of the period
Time zoneZone used to read the scheduleMust match the server schedule
Maximum durationAllowed time between start and endBased on historical run times
Notification channelsWhere alerts are sentEmail, chat, SMS or on-call tools
Parameters that define a heartbeat check

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 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.

MethodDirectionQuestion answeredTypical target
Heartbeat monitoringJob pushes to monitorDid the task run on scheduleCron jobs, backups, queues
Uptime monitoringMonitor polls from outsideIs the service reachableWebsites and public APIs
Health checkLoad balancer or orchestrator pollsIs this instance readyContainers and pool members
Log-based alertingLogs flow to an analyzerDid an error get recordedApplication and error logs
Metrics alertingAgent reports measurementsIs a value outside its rangeCPU, disk and latency
Heartbeat monitoring and neighboring techniques

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.

WorkloadRecommended patternReason
Nightly backup scriptStart and success pings with maximum durationDetects both missed and stuck runs
Frequent queue workerPing every few minutes from the main loopReveals a hung process quickly
Certificate renewalDaily ping with a generous grace periodFailures matter days before expiry
Serverless scheduled functionPing from the function after work completesNo host exists to monitor directly
Data pipeline stepFailure ping with exit code or log excerptSpeeds up diagnosis of known errors
Choosing a heartbeat pattern for different workloads

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.