Run a Kubernetes CronJob at 10 am on weekends
The Kubernetes expression for “Weekends at 10 am” is 0 10 * * 0,6. 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 10 * * 0,6Open in tool“At 10:00, only on Sunday and Saturday”
CronJob manifest
apiVersion: batch/v1
kind: CronJob
metadata:
name: weekends-at-10am
spec:
schedule: "0 10 * * 0,6"
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 weekends-at-10am"]Kubernetes gotchas
FAQ
What is the Kubernetes cron expression for “Weekends at 10 am”?
0 10 * * 0,6. It reads: At 10:00, only on Sunday and Saturday
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.