{
  "id": 22968138,
  "title": "How to monitor cron jobs (and know when they silently fail)",
  "url": "https://urgent.news/2026/12/01/how-to-monitor-cron-jobs-and-know-when-they-silently-fail",
  "topic": "tech",
  "section": "Tech",
  "published": "2026-12-01T15:01:55.000Z",
  "source": {
    "name": "Dev.to",
    "slug": "dev-to",
    "url": "https://dev.to/pingstack/how-to-monitor-cron-jobs-and-know-when-they-silently-fail-5m6"
  },
  "original_language": null,
  "account": "Cron jobs are designed to start a command at a specified time, but they do not verify if the command succeeded or fail if it didn't run due to various reasons. Often, these silent failures go unnoticed until they become critical, such as when a backup stops working. There are two primary types of failure: the job runs and fails, or the job doesn't run at all. To monitor cron jobs and detect these silent failures, a heartbeat check, also known as a dead man's switch, should be implemented. This involves creating a check that the job calls when it completes successfully within a specified grace period. If the check does not receive a response within the grace period, an alert is triggered.\n\nTo set up a heartbeat check effectively, it's crucial to avoid common pitfalls. For instance, pinging the check after the job's command, even if it fails, or placing the ping URL in the crontab, which anyone can access, are significant mistakes. Instead, the ping URL should be kept secure, accessible only to the job's user or stored in a secret management system. It's also essential to use the same schedule and time zone for the check and the job, as cron schedules are time-zone sensitive. If the job's run time varies significantly, the grace period should be adjusted accordingly to account for the longest expected duration. Additionally, if a job can run multiple times at once, implementing a lock mechanism like 'flock' can prevent conflicts between runs.\n\nThe heartbeat check can also be used to detect if a job is performing incorrectly, such as when it exits with a non-zero status code or writes the wrong output. This can be accomplished by including additional data, like the size of the backup or the number of rows processed, in the ping request and setting specific thresholds for alerts. This approach ensures that not only does the job run on time, but it also performs its intended function correctly. The heartbeat check can be implemented across various scheduling systems, including crontab, systemd timers, Kubernetes CronJobs, and GitHub Actions, by following the provided recipes for each system.",
  "summary": "Cron has one job: start a command at a time. It doesn’t check whether the command worked, and it can’t tell you about runs that never started. Nobody looks for those, so they cost the most. The backup that stopped in March gets noticed in June, when someone needs a restore. The ways a cron job fails There are two kinds of failure, and you catch them in different ways. The job runs and fails. The…",
  "summary_source": "publisher",
  "key_points": [
    "Implement a heartbeat check to monitor cron job success",
    "Secure the ping URL, accessible only to the job's user",
    "Adjust grace period based on job's run time and schedule"
  ],
  "editors_take": null,
  "opinion": false,
  "illustration": null,
  "coverage": {
    "outlets": 1,
    "also_reported_by": []
  },
  "machine_translated": false,
  "ai_generated": true,
  "disclaimer": "Accounts, briefs, key points, the editor’s take and translations are written by software from other outlets’ reporting and may contain errors. A summary whose summary_source is \"publisher\" is the outlet’s own feed text. Always check the linked original."
}