Every production cluster has work that does not fit the always-on model of a Deployment: nightly database backups, report generation, queue draining, data migrations, and cleanup tasks. Running these as ad-hoc scripts on a single server is fragile — the server can reboot, the script can fail silently, and nobody notices until a customer complains. Kubernetes Jobs CronJobs solve this problem by giving batch and scheduled work the same reliability guarantees as the rest of your cluster: automatic retries, scheduling, history, and cleanup. In this guide, you will learn how to create, monitor, and troubleshoot Kubernetes Jobs CronJobs so your batch tasks run on time, every time.

Prerequisites
Before you start, make sure you have the following:
- A working Kubernetes cluster (local Minikube or Kind is fine for practice, or any managed cluster for production).
kubectlinstalled and configured to talk to your cluster. Verify withkubectl cluster-info.- A dedicated namespace for practice, so your experiments stay isolated from other workloads.
- Basic familiarity with YAML manifests and Pod specifications.
If you are still getting comfortable with cluster fundamentals, read our guide on Kubernetes ConfigMaps and Secrets first — Jobs and CronJobs very often consume configuration and credentials through those objects.
Kubernetes Jobs CronJobs: Core Concepts
A Job creates one or more Pods and ensures a specified number of them complete successfully. Unlike a Deployment, which keeps Pods running forever, a Job is finished when its Pods succeed, and it will not recreate them afterward. A CronJob is a Job factory: it creates a new Job on a recurring schedule written in cron format, just like the crontab on a Linux server, but with cluster-level reliability.
Three fields control most Job behavior:
completions— how many Pods must succeed before the Job is complete (default 1).parallelism— how many Pods may run at the same time.backoffLimit— how many times Kubernetes retries a failed Pod before marking the Job as failed (default 6).
One important detail: the Pod template inside a Job must set restartPolicy to Never or OnFailure. The default value Always is not allowed, because a Job Pod is supposed to terminate.
Step 1: Create Your First Kubernetes Job
Save the following manifest as hello-job.yaml. It runs a Pod that prints a message and sleeps briefly, simulating a short batch task:
apiVersion: batch/v1
kind: Job
metadata:
name: hello-job
spec:
backoffLimit: 3
template:
spec:
containers:
- name: hello
image: busybox:1.36
command: ["sh", "-c", "echo Hello from Kubernetes Jobs CronJobs; sleep 10"]
restartPolicy: Never
Apply it and watch it run:
kubectl apply -f hello-job.yaml
kubectl get jobs
kubectl get pods --selector=job-name=hello-job
kubectl logs job/hello-job
When the Pod exits with code 0, the Job status changes to Complete. Inspect the details with kubectl describe job hello-job, which shows start time, completion time, and the number of succeeded Pods. This short feedback loop is what makes Kubernetes Jobs CronJobs easy to test before you trust them with real work.
Step 2: Run Parallel Work With Completions
Many batch tasks split naturally into independent pieces — processing a set of files, for example. Set completions and parallelism to spread the work across several Pods:
apiVersion: batch/v1
kind: Job
metadata:
name: batch-worker
spec:
completions: 5
parallelism: 2
template:
spec:
containers:
- name: worker
image: busybox:1.36
command: ["sh", "-c", "echo Processing one unit of work; sleep 20"]
restartPolicy: Never
Kubernetes runs at most two Pods at once and keeps starting new ones until five have succeeded. If one Pod fails, only that unit of work is retried, not the whole batch — one of the main advantages of Kubernetes Jobs CronJobs over a single long-running script. This fan-out pattern is exactly the kind of workload Kubernetes Jobs CronJobs handle far better than a shell loop on one machine.
Step 3: Schedule Recurring Work With a CronJob
Now turn a one-off Job into a recurring task. The manifest below runs a backup-style task every day at 02:30:
apiVersion: batch/v1
kind: CronJob
metadata:
name: nightly-backup
spec:
schedule: "30 2 * * *"
successfulJobsHistoryLimit: 3
failedJobsHistoryLimit: 1
jobTemplate:
spec:
template:
spec:
containers:
- name: backup
image: busybox:1.36
command: ["sh", "-c", "echo Backing up data; sleep 30"]
restartPolicy: OnFailure
The schedule uses standard cron syntax: minute, hour, day of month, month, day of week. A few useful examples:
"*/15 * * * *"— every 15 minutes."0 9 * * 1"— every Monday at 09:00."0 0 1 * *"— on the first day of every month at midnight.
Apply it with kubectl apply -f nightly-backup.yaml, then list the Jobs it creates with kubectl get jobs and the CronJob itself with kubectl get cronjobs. Note that nothing runs until the next scheduled time — a CronJob does not execute immediately on creation. Once the first scheduled run appears, you have a working example of Kubernetes Jobs CronJobs running on a real schedule.
Step 4: Control Missed Runs, Overlaps, and Timezones
Three fields decide what happens when reality interferes with the schedule:
startingDeadlineSeconds— if the controller misses a scheduled start by more than this many seconds (for example, because the cluster was down), the run is counted as failed instead of starting late.concurrencyPolicy—Allow(default) lets runs overlap,Forbidskips a new run while the previous one is still running, andReplacekills the old run to start the new one. For backups,Forbidis usually the safe choice.timeZone— since Kubernetes 1.27, you can pin the schedule to a named timezone (for example,America/New_York) instead of relying on the controller’s local time, which is usually UTC.
spec:
schedule: "30 2 * * *"
timeZone: "UTC"
concurrencyPolicy: Forbid
startingDeadlineSeconds: 120
Step 5: Trigger a Run Manually and Clean Up
Sometimes you need to run a scheduled task on demand — after fixing a bug, for example. Create a one-off Job from an existing CronJob without duplicating its manifest:
kubectl create job manual-backup --from=cronjob/nightly-backup
kubectl logs job/manual-backup
Old Jobs accumulate quickly on a busy cluster. Keeping history tidy is part of operating Kubernetes Jobs CronJobs responsibly, and two mechanisms do the work for you: successfulJobsHistoryLimit and failedJobsHistoryLimit on the CronJob (shown above), and ttlSecondsAfterFinished on a Job, which deletes the Job and its Pods automatically after the given number of seconds:
spec:
ttlSecondsAfterFinished: 3600
To pause all future runs without deleting the CronJob, suspend it with kubectl patch cronjob nightly-backup -p '{"spec":{"suspend":true}}' and resume it by setting suspend back to false.
Kubernetes Jobs CronJobs Troubleshooting
Most Kubernetes Jobs CronJobs failures fall into a few familiar patterns, and each has a quick diagnosis:
Job stuck in a retry loop
If a Job keeps creating new Pods, check the Pod logs first — the container itself is usually failing. Remember that backoffLimit counts Pod failures, and the delay between retries grows exponentially, so a Job can look idle while it is actually waiting to retry. Use kubectl describe job to see the failure count and the last error message.
CronJob never runs
Verify the schedule syntax and the timezone. A common mistake is writing a schedule in local time while the controller interprets it as UTC. Also check kubectl get cronjob nightly-backup — the LAST SCHEDULE column tells you whether any run has ever been triggered, and a suspended CronJob shows SUSPEND as True.
Pods fail with ImagePullBackOff or CrashLoopBackOff
These are Pod-level problems, not Job problems: a wrong image name, a missing registry credential, or a command that exits immediately. Fix the image or command in the template, delete the failed Job, and reapply. Jobs do not pick up template changes automatically — you must recreate the Job.
Runs overlap and corrupt data
If two instances of a task run at the same time and conflict (for example, two backups writing to the same file), set concurrencyPolicy: Forbid and consider adding startingDeadlineSeconds so stale runs are dropped instead of piling up.
Conclusion
Kubernetes Jobs CronJobs turn fragile one-off scripts into managed, observable, retryable workloads. Start with a simple Job, add parallelism when a task splits into pieces, schedule it with a CronJob, and protect it with sensible history limits, concurrency policy, and timezone settings. Treat Kubernetes Jobs CronJobs as first-class workloads, not afterthoughts, and your batch work stops depending on a single server staying healthy — and stops waking you up at night. For the official field reference and advanced options such as indexed Jobs, see the Kubernetes Jobs documentation and the Kubernetes CronJobs documentation.