Kubernetes YAML Workloads/Basic CronJob YAML

Schedule recurring batch work.

Section: Jobs and CronJobs

Basic CronJob YAML

yaml
yaml
apiVersion: batch/v1
kind: CronJob
metadata:
  name: nightly-report
spec:
  schedule: "0 2 * * *"
  concurrencyPolicy: Forbid
  successfulJobsHistoryLimit: 3
  failedJobsHistoryLimit: 1
  jobTemplate:
    spec:
      template:
        spec:
          restartPolicy: Never
          containers:
            - name: report
              image: ghcr.io/example/reporter:1.0.0
              args: ["generate"]

Learn the surrounding workflow

Compare similar commands or jump into common fixes when this command is part of a bigger troubleshooting path.

Related commands

Same sheet · prioritizing Jobs and CronJobs
Basic Job YAML
Run a one-time batch task with retries.
OpenIn sheetyamlsame section
Run CronJob template on demand
Instantiate a Job from a CronJob definition.
OpenIn sheetbashsame section
Basic StatefulSet YAML
Run stateful replicas with stable ordinals.
Basic DaemonSet YAML
Deploy a log collector or node agent everywhere.
HorizontalPodAutoscaler YAML
Scale Deployment based on CPU utilization.
Set rolling update partition
Control StatefulSet ordinal rollout.