Blog

Cron Job Monitoring: Tell a Missed Run from a Failed Run

Use schedule and run history to distinguish missed, failed, and slow jobs across cron, systemd timers, and Kubernetes CronJobs.

Cron Job Monitoring: Tell a Missed Run from a Failed Run
Cron Job Monitoring: Tell a Missed Run from a Failed Run

The nightly export is missing at 07:00. Before changing the script, find out whether the scheduler started it. A missed run, a failed command and a command that is still running point to three different checks.

Missed: was a run due, and did anything start?

Open Scheduled jobs for the fleet or cluster. Check the job's schedule, time zone, next run and recent history. In the WatchLog website example, the daily cron task was due at 06:25 and no start was seen. For a missed run, check the scheduler and machine before opening application logs. Was the server up and the agent observing it? Was a timer disabled or a CronJob suspended? Account for randomized systemd delays, catch-up after reboot and clock changes. No record from before monitoring started does not show that the scheduler missed a run.

Failed: what did the last run report?

A failed run did start. Compare its exit code and failure streak with the last good run. On a systemd timer, check the service unit it triggers as well as the timer itself; the service's journal normally has the useful error. For a Kubernetes CronJob, inspect the Job created for that scheduled time, then the failed pod and its container logs. The website example's backup timer reached the service three times and returned exit code 2. That narrows where to investigate, but the code alone does not establish a cause.

WatchLog demo: failed CronJob runs and exit codes.

Slow: is the work stuck or just larger than usual?

Compare elapsed time with recent successful runs, then check whether the input grew, the destination slowed down or a lock blocked progress. WatchLog's slow-job check needs five good runs and flags a run that is at least three times its usual duration and at least five minutes longer. If you're considering rerunning it, check whether a previous instance is still running and whether concurrent jobs would overwrite output or repeat side effects.

Understand what your collector can prove

systemd supplies its own run history. The Kubernetes view follows Jobs created by a CronJob and can show a failed pod's exit code when available. On Linux cron, eBPF records the process lifecycle, including exit status. Supported text logs can show a start without an exit code; without usable run evidence, a job can be listed with no run alerts. A passing run also does not prove a backup is restorable. Verify the resulting artifact and periodically test a restore separately.

Explore the WatchLog scheduled jobs example and how each scheduler is monitored.

See your own servers in five minutes.

Free on WatchLog Cloud for 5 servers or nodes, or run it yourself, open source.