Heartbeat Monitoring for Cron Jobs: Alert on Silent Failures
Nightly backups, billing exports, and ETL syncs rarely crash loudly—they simply stop reporting and everyone discovers the mess during business hours.
Cron jobs fail silently more often than you think
Even well-tested automation can miss a run because infrastructure, credentials, or humans get in the way.
Servers reboot and crontab entries never restart, so tasks stop executing altogether.
A dependency (database, bucket, third-party API) stalls and your script exits early without reporting it.
Engineers pause a job during an incident and forget to re-enable it.
Credentials expire, your script retries forever, and no one reads the logs until customers complain.
What PingHarbor heartbeats watch for
Heartbeat monitoring turns every cron job into a monitored workflow. Each task receives a unique URL; when it finishes successfully it pings the URL. If PingHarbor doesn’t hear from that job within its frequency plus grace window, an incident opens.
Setup in under five minutes
Create a heartbeat monitor inside PingHarbor, pick a frequency (e.g., hourly) and a grace period (e.g., 10 minutes).
Copy the generated webhook URL and add a ping at the successful end of your script.
Optionally include metadata in the request body (records processed, duration, host) for richer audit trails.
Choose which alert channels should fire when a beat is missed.
Bash example
#!/bin/bash
run_backup
curl -fsS -X POST $PINGHARBOR_HEARTBEAT_URL \
-H 'Content-Type: application/json' \
-d '{"job":"nightly-backup","status":"ok"}'
Node.js example
import fetch from 'node-fetch';
await fetch(process.env.PINGHARBOR_HEARTBEAT_URL, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ job: 'etl-sync', durationMs })
});
Python example
import os, requests
requests.post(os.environ['PINGHARBOR_HEARTBEAT_URL'], json={
'job': 'ci-deploy',
'status': 'ok',
'commit': commit_sha
})
Alerting & workflows
Missed heartbeats trigger the same multi-channel routing you already use for uptime monitors: Email, SMS, Slack, Teams, PagerDuty, WhatsApp, or custom webhooks. Send structured payloads into n8n or Linear to auto-open incidents, or have OpenClaw runbooks query `list_heartbeat_monitors` before paging an engineer.
Best practices for reliable automations
Create one heartbeat per critical job so you know exactly what failed.
Always ping on success and failure (with a `status` flag) so you can separate soft warnings from broken runs.
Set grace periods that reflect reality: backups might need 30 minutes while health checks need 2.
Annotate pings with payload data (records, duration, host) to trend performance over time.
Use PingHarbor’s tagging to group jobs by team and route alerts to the right rotation.
Automate with MCP + OpenClaw
Because heartbeat monitors ship in the PingHarbor MCP server, any OpenClaw agent can spin up new monitors, confirm the latest beat, or pull SLA reports in seconds. Ask an agent to “show me which cron jobs missed their last beat” before you dive into logs.
Ship reliable nightly jobs
Heartbeat monitoring is live on every PingHarbor plan. Add the webhook to your next cron job and turn silent failures into actionable alerts before customers feel the impact.