Sub topic 9
Missed Runs and startingDeadlineSeconds
This chapter assumes you can write a basic CronJob manifest and read its schedule. It also assumes you know how concurrencyPolicy works. Here you will learn what Kubernetes counts as a missed run and how startingDeadlineSeconds controls the response.
What counts as a missed run
The CronJob controller checks its CronJobs about every 10 seconds. For each CronJob, it compares the schedule with the time of the last run. Any scheduled time that has passed without a Job being created is a missed run.
Common causes:
- The control plane was down or restarting at the scheduled time.
concurrencyPolicy: Forbidskipped the run because the previous Job was still active.- The CronJob was suspended and then resumed.
When several runs were missed, the controller creates only the most recent one. It does not replay the whole backlog.
What startingDeadlineSeconds does
startingDeadlineSeconds is the number of seconds after a scheduled time during which the controller may still start that run. If the deadline has passed, the run is skipped and counted as missed. The controller also records a warning event on the CronJob.
Without this field, a late run can start at any time after its scheduled moment. In that case the CronJob has no deadline.
Example
This CronJob must start within 10 minutes of 02:30 UTC. If the controller is unavailable until 02:45, the 02:30 run is skipped. The next attempt is at 02:30 the following day.
apiVersion: batch/v1
kind: CronJob
metadata:
name: nightly-report
spec:
schedule: "30 2 * * *"
timeZone: "Etc/UTC"
concurrencyPolicy: Forbid
startingDeadlineSeconds: 600
jobTemplate:
spec:
template:
spec:
restartPolicy: OnFailure
containers:
- name: report
image: busybox:1.36
command: ["sh", "-c", "date; echo generating report"]The 100 missed runs limit
The controller stops scheduling a CronJob if it counts more than 100 missed runs. The counting window depends on the deadline:
- If
startingDeadlineSecondsis unset, the controller counts all misses since the last run. A CronJob that runs every minute breaks after about 100 minutes of downtime or suspension. - If it is set, the controller counts only misses inside the deadline window. A short deadline keeps the count low, so the CronJob recovers by itself.
When the limit is hit, the controller logs an error like too many missed start times (> 100) and does not start the Job until you fix the cause. Setting a deadline prevents this.
Choosing a value
Pick a deadline from how late a run can start and still be useful. A report that must finish before 06:00 can tolerate a late start. A health check that is only valid at its scheduled time cannot.
Keep these limits in mind:
- Because the controller checks about every 10 seconds, a value under 10 may mean the run never starts.
- The deadline applies to starting a run, not to how long it runs. Use
activeDeadlineSecondsin the Job spec to limit run time. - A deadline does not retry anything. A skipped run is only visible through events and the missing Job.
Checking for missed runs
kubectl describe cronjob nightly-report
kubectl get jobs --sort-by=.metadata.creationTimestamp
kubectl get events --field-selector involvedObject.name=nightly-reportCheck Last Schedule Time in the describe output and look for warning events about missed start times. If a gap in your Job list has no matching event, check whether the CronJob was suspended.
Exercise
A CronJob runs every minute and has no startingDeadlineSeconds. It was suspended for two hours and then resumed. What happens, and how do you prevent it?
Show answer
More than 100 runs were missed, so the controller logs "too many missed start times" and does not start any Job. Setting startingDeadlineSeconds (for example 60) means only misses inside that window are counted, so the CronJob resumes normally after the suspension.