Menu

Star on GitHub · 3.1k
All posts
Essential Guide

Heartbeat monitoring for cron jobs

Cron jobs fail without making a sound. Heartbeat monitors tell you when a job did not run, ran late or never finished.

Heartbeat monitoring for cron jobs

Cron jobs are the quietest part of most systems. Backups, billing runs, report emails and cleanup tasks run on a schedule, and when they stop, nothing errors. Nobody notices until a customer asks why their invoice never arrived. Heartbeat monitoring fixes that.

1. How a heartbeat works

A heartbeat monitor turns the usual check around. Instead of Navy calling your service, your job calls Navy. Each heartbeat monitor has a unique URL, and your job sends a request to it every time it runs.

2. Set the expected schedule

Tell Navy how often the job should run, like every hour or every day at 02:00 UTC. If a ping does not arrive on time, Navy treats the job as missed and opens an incident. You can use cron syntax directly.

3. Add a grace period

Jobs do not always run to the second. A grace period gives a job a little extra time before it counts as late. A nightly backup might get 15 minutes. A job that runs every minute might get 30 seconds.

4. Track start and finish

Send one ping when the job starts and another when it finishes. Navy then knows the job is running, how long it took and whether it got stuck. A job that started and never finished is often worse than one that never ran.

5. Report failures explicitly

If your job catches an error, send a failure ping instead of waiting for the schedule to run out. Navy alerts right away and records the failure on the monitor. You find out in seconds instead of at the next expected run.

6. Keep it to one line

Adding a heartbeat should not need a library. A single curl call at the end of a script is enough. For jobs that run in containers or serverless functions, the same HTTP request works from anywhere.

7. Route alerts like any other monitor

Heartbeat monitors use the same alert channels and escalation policies as your HTTP and TCP monitors. A missed billing run can page on-call, while a late cleanup job can post to Slack.

Job Schedule Grace period
Database backup Daily at 02:00 UTC 15 min
Invoice run Hourly 5 min
Queue cleanup Every minute 30s

If a job matters enough to schedule, it matters enough to monitor. Add a heartbeat to every cron job you would be unhappy to find broken a week later.

Keep reading

More from on call

View all posts
Monitors as code with Terraform
researchMay 29, 2025

Monitors as code with Terraform

Define your monitors, alerts and status pages next to the infrastructure they watch, with the Navy Terraform provider.

What a status page should say during an incident
essential-guideMay 27, 2025

What a status page should say during an incident

Customers do not need every detail during an outage. They need clear, regular and honest updates. Here is what to write.

See inside your cloud: agentic pentesting for AWS
productOct 12, 2026

Awshook: 173 programs for AWS offense

Awshook is 173 deterministic programs that walk the full MITRE ATT&CK kill chain against an AWS account, from recon to impact, all through the AWS CLI and REST APIs.

Get the next post in your inbox

One email a month with new posts, product updates and the odd postmortem worth reading. Unsubscribe in one click.