Run a Kubernetes CronJob at 9 am on weekdays
The Kubernetes expression for “Weekdays at 9 am” is 0 9 * * 1-5. Below: config you can paste, the next run times, and what to watch out for. A Kubernetes CronJob reads five-field cron in spec.schedule and starts a Job for each run.
0 9 * * 1-5Open in tool“At 09:00, Monday through Friday”
CronJob manifest
weekdays-at-9am.yaml
apiVersion: batch/v1
kind: CronJob
metadata:
name: weekdays-at-9am
spec:
schedule: "0 9 * * 1-5"
timeZone: "Etc/UTC"
concurrencyPolicy: Forbid
startingDeadlineSeconds: 300
jobTemplate:
spec:
template:
spec:
restartPolicy: OnFailure
containers:
- name: job
image: busybox:1.37
command: ["sh", "-c", "echo running weekdays-at-9am"]Kubernetes gotchas
Day of week is 0-6The schedule parser stops at 6. Write 0 for Sunday; 7 is an error.
Too many missed startsIf a CronJob misses more than 100 starts, the controller stops starting it. Set startingDeadlineSeconds so old misses stop counting.
Overlapping runsconcurrencyPolicy defaults to Allow, so a slow Job can overlap the next one. Use Forbid or Replace.
*/n in a day field counts as setOnly * or ? leave a day field open. 0 0 */2 * 1 runs on odd days or on Mondays, while Vixie cron reads it as odd days that are Mondays.
FAQ
What is the Kubernetes cron expression for “Weekdays at 9 am”?
0 9 * * 1-5. It reads: At 09:00, Monday through Friday
Which time zone does a Kubernetes schedule use?
Without spec.timeZone, in the local zone of kube-controller-manager, which is usually UTC. Set spec.timeZone (stable since Kubernetes 1.27) to an IANA name. CRON_TZ or TZ inside schedule is rejected.
Does a CronJob support @daily?
Yes. @yearly, @monthly, @weekly, @daily and @hourly work in spec.schedule.
Why did my CronJob run twice, or not at all?
A CronJob creates about one Job per scheduled time, not exactly one. Make the Job safe to repeat, and check startingDeadlineSeconds and concurrencyPolicy.