← Monitoring guides

How to monitor cron jobs with heartbeat alerts

By PingCron · Updated

To monitor a cron job, send a heartbeat after the work succeeds and use an independent monitor to expect the next check-in. If that check-in is missing beyond the allowed grace period, the monitor can alert you. Start with one job, confirm its receipt, then test a missed run and recovery.

For plan limits and a shell wrapper that preserves your workload’s exit status when reporting fails, see cron job monitoring. Monitoring a data pipeline? Use ETL job monitoring to define success after the load and required validation.

1. Send a heartbeat only after successful work

For a Bash job in a user crontab, append a bounded HTTP request to the command you already run. Replace YOUR_MONITOR_SUCCESS_URL with the private success URL from your monitor. Keep this as one physical crontab line:

0 2 * * * /scripts/backup.sh && curl --max-time 10 -fsS YOUR_MONITOR_SUCCESS_URL >/dev/null

The shell’s && runs curl only if the workload exits successfully. Your script must exit nonzero on failure; swallowed errors can produce false success. If completion means a backup file exists or rows were written, check that output before sending the heartbeat.

Create a free monitor for this job

Creating a monitor gives you its heartbeat URL. Free includes 5 monitors, 7-day receipt history, and email, Slack, and Discord alerts. No credit card required.

Why monitor cron jobs if you already have logs?

Logs help explain a run that happened. An independent heartbeat monitor also notices an expected completion that never arrives, including when the scheduler or host stops. Cron email requires working mail delivery and cannot send from a powered-off host. Keep logs for diagnosis; use the heartbeat to detect missing completion. Neither replaces checks that the output is correct.

A healthy server does not guarantee that each scheduled job completed. A stopped timer, removed cron entry or job that runs past its expected deadline can leave the host reachable while a backup becomes overdue. A success-only heartbeat can add coverage when your existing monitoring does not independently alert if that job misses its completion deadline. If it already does, another heartbeat service may duplicate that coverage. A missing heartbeat can also mean the check-in request failed, so investigate before treating the alert as proof that the job failed.

2. Match the schedule, timezone, and grace period

In PingCron, create a monitor with either a five-field cron schedule and timezone or an interval. The monitor observes your job; it does not schedule or execute it. Use one monitor per non-overlapping workload so one job cannot hide another’s failure.

A fixed clock time and an elapsed interval are different expectations
Your jobMonitor settingWhat it expects
Daily at 02:00 UTC0 2 * * *, timezone UTCThe next matching 02:00 appointment, plus grace
Every 24 hours after the last receipt1d interval24 elapsed hours after the latest success or failure receipt, plus grace

Grace period example: a daily backup

Suppose an already-active job is due at 02:00 UTC and normally takes 6 minutes. Allow another 4 minutes for normal scheduler and network delay: set grace to 10 minutes. Completion by 02:10 UTC is within that allowance. Without a completion, the monitor becomes overdue after the deadline; periodic checks and delivery processing mean this is not a promise of notification at exactly 02:10.

Match the monitor timezone to the scheduler and account for daylight-saving changes. Choose grace from actual runtime and tolerable delay, not to silence unexplained failures. A new monitor waits for its first receipt. For daily or weekly work, verify installation before relying on the next scheduled run.

3. Monitor Python, Node.js, and explicit failures

The same success-only pattern works for other workloads. These are user crontab entries; a system /etc/crontab entry also needs a username field. Use absolute paths, keep each entry on one physical line, and put comments on separate lines.

Python workload launched by cron

0 2 * * * /opt/app/.venv/bin/python /opt/app/job.py && curl --max-time 10 -fsS YOUR_MONITOR_SUCCESS_URL >/dev/null

Node.js workload launched by cron

0 2 * * * /usr/bin/node /opt/app/job.js && curl --max-time 10 -fsS YOUR_MONITOR_SUCCESS_URL >/dev/null

The curl option --max-time 10 limits each HTTP request to 10 seconds; it does not stop a long-running job. These simple commands can return curl’s exit status after a successful workload. Use the wrapper below when you need to preserve the workload’s status and report a failure explicitly.

Optional start and failure signals

For a more explicit integration, run this wrapper from cron after replacing the workload path. The heartbeat calls have time limits. A telemetry error stays visible on standard error but does not skip the workload, replace its exit code, or turn a failed success request into a workload-failure report.

#!/bin/sh
# Supply the actual monitor URL through your job environment.
: "${PINGCRON_URL:?Set the monitor success URL}"
curl --max-time 10 -fsS "$PINGCRON_URL/start" >/dev/null || :
if /path/to/your-job; then
  curl --max-time 10 -fsS "$PINGCRON_URL" >/dev/null || :
else
  job_status=$?
  curl --max-time 10 -fsS "$PINGCRON_URL/fail" >/dev/null || :
  exit "$job_status"
fi

Set PINGCRON_URL in the environment that cron actually uses, or load it from a protected configuration file in your wrapper. Exporting it in an interactive terminal does not automatically provide it to cron. Make the wrapper executable and schedule its absolute path.

A start receipt does not prove success. In PingCron, a started run must finish within grace, or an earlier scheduled deadline if one applies. Repeated starts do not extend that deadline. Concurrent executions need separate monitors; this pattern does not correlate overlapping runs by run ID.

4. Verify a real run, a missed run, and recovery

Want email, Slack, or Discord notifications? Set up cron job alerts and verify your destination.

  1. Destination: save your email or other eligible destination in Settings, send a labeled test, and confirm receipt. This checks delivery configuration, not missed-run detection.
  2. Scheduled work: run the actual job through its scheduler. Check its output and confirm a successful heartbeat in the monitor’s history. A manually sent heartbeat only proves endpoint connectivity.
  3. Missed run and recovery: create an isolated test monitor with a short interval, send its first success, then withhold the next heartbeat beyond interval plus grace. Confirm the overdue state and actual alert receipt. Send a success again and check recovery and delivery history. Pause the disposable monitor when finished.

Provider acceptance is not inbox delivery. A heartbeat is not proof of data correctness. For backups, keep independent restore drills; for data pipelines, validate the rows or outputs that matter.

For a comparison of logs, metrics, and heartbeat monitoring, read our companion cron job monitoring guide on Google Sites. It includes a Bash walkthrough and output checks for backups, scheduled scripts, and data synchronization.

Cron job not running? Work through these checks

  • Schedule: check the cron fields and scheduler timezone with the crontab validator. Account for daylight-saving transitions.
  • Execution context: verify the scheduler is enabled, the right user owns the job, and paths, permissions, environment variables, and credentials exist in the scheduled environment.
  • Workload: inspect its logs and exit status. A successful launcher may only have queued work elsewhere.
  • Heartbeat: confirm the URL belongs to this monitor, outbound HTTPS works, and the success call executes only after required work.
  • Alerts: check whether the monitor has received its first check-in, is paused, or is still within grace. Review saved destinations and delivery attempts.

Use the guide for your scheduler

Start with one job you need to trust

Free is enough to verify your first job: 5 monitors, 7-day receipt history, and email, Slack, and Discord alerts. Finish setup and confirm an alert before adding more jobs.

Monitor my first cron job free

When Pro earns its place

Need more than 5 jobs, longer incident context, or alerts sent to a custom webhook? Pro is $9.99/month for one account owner, with up to 50 monitors and 30-day receipt history. Ordinary email, Slack, and Discord alerts do not require Pro. For shared account access, see the Team plan.

Choose Pro — $9.99/month

Create your account, then continue to checkout for the paid subscription.