Monitor Any Cron Job With One Line of curl

Tutorial · 2026-12-07 · 5 min read

You do not need to install an agent on every server to watch a cron job. Cron already knows how to run a command — so the entire monitoring system can be one more command at the end of the job.

The trick is to invert the usual monitoring logic. Rather than installing something that watches the job, you make the job itself report that it finished. This is a dead-man's switch: silence is the alarm.

The one line

At the end of a job, append a curl call to a unique heartbeat URL:

0 2 * * * /opt/backup.sh && curl -fsS https://your-host/ping/41a96d09ad

That is the whole integration. The && is what makes it meaningful: the heartbeat is sent only if the script exits successfully. If the script fails, or never runs, no heartbeat arrives.

Why -fsS matters

Together they make the heartbeat invisible when healthy and loud when broken.

Set the deadline correctly

Two numbers define when an alert fires: the period (how often the job should check in) and the grace period (how late it may be). A daily backup might use a 1440-minute period with a 30-minute grace — if no heartbeat arrives by 02:30, something is wrong.

# every 5 minutes, allow 2 minutes of slack
*/5 * * * * /opt/sync.sh && curl -fsS https://your-host/ping/your-short-id
Set the grace period longer than the job's worst realistic runtime. A backup that sometimes takes 40 minutes needs at least a 45-minute grace, or you will train yourself to ignore alerts.

Why not just use cron mail?

Cron can email output, but that assumes mail delivery works, somebody reads the inbox, and the job actually ran. A job that never starts sends no mail. A heartbeat monitor detects the absence of the signal itself — which is a fundamentally more reliable check.

Where the heartbeat URL comes from

A monitoring service issues each check a unique, unguessable short ID. That ID is the only thing exposed to the job. No credentials live in the crontab, and a leaked URL reveals only that one check's existence.

With a self-hosted tool like TickAlive, the heartbeat endpoint runs on your own host and the alert goes out through Telegram or WeCom. The next guide walks through the notification side.

Know the moment a job stops

TickAlive is a self-hosted dead-man's switch for cron jobs. One curl line to plug in — Telegram or WeCom alerts when a job goes quiet.

Get TickAlive — $19
croncurldead-man's switch
← All articles Next article →