Skip to content

How to Monitor Cron Jobs

Key idea:

Cron jobs silent-fail — the most common cause of data loss. Default cron: on error, email (if SMTP set up), otherwise nothing. Right approach: heartbeat monitoring (dead-man's switch) — cron pings a URL on success, monitoring service waits for a ping and alerts if missed. Solutions: Enterno Heartbeat, Healthchecks.io, Cronitor.

Below: step-by-step, working examples, common pitfalls, FAQ.

Step-by-Step Setup

  1. Create a heartbeat monitor at Enterno Heartbeat → get a unique ping URL
  2. Add curl to the end of your cron line: 5 2 * * * /usr/bin/backup.sh && curl -fsS PING_URL
  3. For logging failures: curl -fsS PING_URL/fail on the error path
  4. Set expected interval (hourly = 60 min grace period)
  5. Configure alerts: Email/Telegram/Slack on missed ping
  6. Verify: comment the cron → after expected time you get an alert
  7. For batch jobs: ping /start at the beginning + /PING_URL at end → measures duration

Working Examples

ScenarioConfig
Simple success ping0 3 * * * /usr/local/bin/backup.sh && curl -fsS https://heartbeat.enterno.io/ping/abc123 > /dev/null
Ping with duration0 3 * * * curl -fsS -m 10 https://heartbeat.enterno.io/start/abc123 && /usr/local/bin/backup.sh && curl -fsS https://heartbeat.enterno.io/ping/abc123
Fail ping on error0 3 * * * /backup.sh || curl -fsS https://heartbeat.enterno.io/fail/abc123
With exit code0 3 * * * (/backup.sh; STATUS=$?; curl -fsS https://heartbeat.enterno.io/ping/abc123/$STATUS)
Systemd timer alternative# /etc/systemd/system/backup.service [Service] ExecStart=/backup.sh ExecStartPost=curl -fsS https://heartbeat.enterno.io/ping/abc123

Common Pitfalls

  • curl missing -fsS flags — silent fail on 500, nothing pings
  • Grace period too low — false positives on short cron delays
  • && between commands: if backup fails, ping skips — that's correct for alerting
  • Ping URL in a git repo — others can ping and hide real failures
  • Multi-step pipeline: needs heartbeat per step, not just the final one
Dead man's switchAlert when job goes silent
Flexible Grace PeriodAllowed ping latency window
REST API PingSingle GET confirms liveness
Cron + CI + ScriptsFor any periodic task

Why teams trust us

1min
min interval
Email
Telegram + Email alerts
HTTP
ping endpoint
Free
5 monitors free

How it works

1

Create heartbeat

2

Ping URL from cron

3

Get alert on miss

What is Heartbeat Monitoring?

A heartbeat monitor is a "reverse monitor": instead of us polling the service, the service signals us that it's alive. If no signal arrives within the set interval — we send an alert.

Simple Integration

One GET request to a unique URL — and the monitor knows the job completed.

Grace Period

Set an acceptable ping delay to avoid false alerts.

Smart Notifications

Email and Telegram on missed ping. Repeated alert if silence continues.

Execution History

Full ping log with timestamps — see every job execution.

Who uses this

DevOps

cron job monitoring

Developers

background worker check

Sysadmins

dead man's switch

Business

payment queue monitoring

Common Mistakes

No grace periodWithout grace period, any minor delay triggers a false alert.
Pinging before task startsPing at the end of the task — it confirms successful completion, not just start.
One URL for different tasksCreate a separate monitor for each cron job — otherwise you won't know which one failed.
Not pinging on errorIf the task fails — don't ping. Missing ping = failure signal.

Best Practices

Ping at the very endMake the heartbeat URL call the last command in the script.
Use curl in croncurl -s https://enterno.io/api/heartbeat/TOKEN — simple and reliable.
Set grace = 20–30%If the job takes 5 min, grace period = 1–2 min on top.
Cover all critical jobsBackups, report generation, data sync — all should have a heartbeat monitor.

Start monitoring cron for free

Heartbeat monitor: 5 tasks free, Telegram and email alerts on missed runs.

Sign up free

Learn more

Frequently Asked Questions

Cron sends email by default — isn't that enough?

Often SMTP isn't configured on a VPS → email never lands. Heartbeat actively alerts when cron didn't start at all (host down, cron daemon stopped).

Healthchecks.io vs Enterno?

Healthchecks — open-source + SaaS free tier. Enterno — integrated with uptime/SSL/DNS monitoring in one dashboard, + RU servers.

Kubernetes CronJob — how?

Same principle: <code>curl PING_URL</code> in postStart/postStop container lifecycle hook. Or a sidecar container.

Private network cron — how to ping?

Outbound HTTP is usually allowed. If not — self-hosted Healthchecks on internal network.