Pro ยท Lesson 7 of 12
A Job runs until it succeeds or hits its limit. A CronJob creates Jobs on a schedule.
Sign in to save your place.
A Job is a boat you send once, with a note that says how many times it may try. A CronJob is the clock that sends that boat every night.
A Job's Pod should use restartPolicy of Never or OnFailure. Always is for long-running Pods, and the API rejects it on a Job.
completions is how many successes you want. parallelism is how many Pods may run at once. backoffLimit is how many failures you tolerate. A Job that ignores a failed container will look green while the work did not happen. Read the Pod status, not only the Job's first line.
| Field | Question it answers |
|---|---|
| completions | How many successful Pods count as done? |
| parallelism | How many may run together? |
| backoffLimit | How many retries before the Job fails? |
A CronJob stores a schedule in cron format and a Job template. concurrencyPolicy is Allow, Forbid, or Replace. Forbid is the one you want when a slow run must not overlap the next night. Replace kills the previous run.
The timeZone field exists on the CronJob API. Confirm it on the cluster version you use before you depend on it. Without it, the schedule is evaluated in the controller's timezone, which you should not guess.
startingDeadlineSeconds decides how late a missed start can still run. Leave it unset only if you understand that a paused controller can later fire a burst of missed jobs.
Step 1 of 3The CronJob does not do the work. It creates a Job.
Step 2 of 3The Job counts successes and failures.
Step 3 of 3The Pod exits. A restart policy of Always does not belong here.
Apply it, wait, and read the logs. Then look at the Job status. Delete the Job when you are done so it does not sit in the namespace.
kubectl apply -f - <<'EOF'
apiVersion: batch/v1
kind: Job
metadata:
name: once
spec:
backoffLimit: 2
template:
spec:
restartPolicy: Never
containers:
- name: work
image: busybox:1.36
command: ["sh", "-c", "echo done && exit 0"]
EOF
kubectl wait --for=condition=complete job/once --timeout=60s
kubectl logs job/once
Checked against the linked documentation in October 2026. A later release can move a flag, a price, or a supported pair. Use the page for the version you installed.