CronJobs are the right fit for backups, reports, cleanup, and periodic synchronization tasks.
Interactive guide to recurring Jobs, cron schedules, history retention, and recurring workload behavior.
CronJobs do not replace Jobs; they create Jobs on a schedule. The scheduling layer and the execution layer are separate and that distinction matters.
k8s/labs/workloads/cronjob.yaml — CronJob that creates Jobs on a cron schedule.k8s/labs/workloads/cronjob-timezone.yaml — CronJob example using time zone scheduling fields where supported.CronJobs are the right fit for backups, reports, cleanup, and periodic synchronization tasks.
You can control how many successful and failed Jobs are retained for inspection.
Scheduled tasks should tolerate repeat runs because retries and overlaps can happen.
Default. Allows multiple Jobs to run at the same time.
Skips new Job if previous Job is still running.
Terminates current Job and starts new one.
apiVersion: batch/v1
kind: CronJob
metadata:
name: hello-cronjob
spec:
schedule: "*/5 * * * *"
successfulJobsHistoryLimit: 3
failedJobsHistoryLimit: 1
kubectl get cronjob
kubectl describe cronjob hello-cronjob
kubectl get jobs
| Feature | CronJob | Job |
|---|---|---|
| Trigger | Time-based schedule | Manual creation or external trigger |
| Creates | Jobs | Pods |
| Use case | Recurring tasks | One-off batch work |
| State to monitor | Schedule plus history | Completion and failure state |
Run scheduled database or file backups at fixed times.
Delete stale files, temporary data, or expired records periodically.
Trigger summary reports or email digests at regular intervals.