Kubernetes CronJob .spec.timeZone, CRON_TZ Rejection, and ConcurrencyPolicy Guide

Configure IANA timezones safely in Kubernetes v1.27+ CronJobs, fix rejected CRON_TZ/TZ prefixes in .spec.schedule, and choose between Forbid and Replace.

Kubernetes v1.27+ batch/v1 CronJob .spec.timeZone GA SpecificationKubernetes CronJob Validation: Disallowed TZ= / CRON_TZ= in scheduleKubernetes CronJob ConcurrencyPolicy (Allow, Forbid, Replace)

Incident Symptom & Protocol Root Cause

Production Failure Symptom

Applying a Kubernetes CronJob with CRON_TZ=America/Chicago 15 4 * * * fails validation (or causes unsupported parser drift), or leaving default concurrencyPolicy: Allow spawns dozens of overlapping pods when an upstream database slows down.

Scheduler Parser & Clock Mechanics

Kubernetes officially prohibits embedding TZ= or CRON_TZ= inside .spec.schedule (which was an undocumented robfig/cron library side effect prior to v1.25) and defaults concurrencyPolicy to Allow alongside pod restartPolicy: OnFailure, creating runaway pod storms when jobs hang.

Broken vs Verified Configuration

BrokenInvalid CRON_TZ Prefix + Unsafe Default Concurrency
apiVersion: batch/v1
kind: CronJob
metadata:
  name: warehouse-etl-sync
spec:
  # Rejected by K8s API validation: CRON_TZ prefix is unsupported!
  schedule: "CRON_TZ=America/Chicago 0 */1 * * *"
  # Omitted concurrencyPolicy defaults to "Allow" -> overlapping ETL corruption!
  jobTemplate:
    spec:
      template:
        spec:
          restartPolicy: OnFailure
          containers:
            - name: sync
              image: registry.internal/etl:1.9.0
Verified FixNative .spec.timeZone + Bounded Forbid & activeDeadlineSeconds
apiVersion: batch/v1
kind: CronJob
metadata:
  name: warehouse-etl-sync
spec:
  schedule: "5 * * * *"
  timeZone: "America/Chicago"
  concurrencyPolicy: Forbid
  startingDeadlineSeconds: 300
  successfulJobsHistoryLimit: 3
  failedJobsHistoryLimit: 3
  jobTemplate:
    spec:
      # Hard cap runtime at 50m so a hung pod cannot block Forbid forever!
      activeDeadlineSeconds: 3000
      backoffLimit: 2
      template:
        spec:
          restartPolicy: Never
          containers:
            - name: sync
              image: registry.internal/etl:1.9.0
              env:
                - name: TZ
                  value: "America/Chicago"

Operational Deep Dive

Since Kubernetes v1.27 (when CronJobTimeZone graduated to GA), .spec.timeZone accepts any valid IANA timezone database string (such as America/Chicago, Asia/Tokyo, or Etc/UTC) and instructs kube-controller-manager to calculate trigger times in that zone. Crucially, setting .spec.timeZone on the CronJob ONLY tells the control-plane scheduler when to create the Job—it does NOT set the TZ environment variable inside your container! If your application logs or SQL queries expect local time, pass env: [{ name: 'TZ', value: 'America/Chicago' }] inside the Pod spec too (or better, keep application internals in UTC).

Choosing concurrencyPolicy requires pairing it with jobTemplate.spec.activeDeadlineSeconds. With the default Allow, an ETL job running every 5 minutes against a locked table spawns 12 concurrent pods per hour until connection pools collapse. Switching to Forbid skips new ticks while a previous Job is still active—but if a pod deadlocks on a network socket without a timeout, Forbid will silently skip every subsequent run forever! Setting activeDeadlineSeconds ensures Kubernetes terminates hung pods and unblocks the next scheduled cycle.

Reserve concurrencyPolicy: Replace only for stateless cache warmers or read-only snapshot jobs that safely handle SIGTERM mid-flight. Under Replace, if the previous Job is still running when the next schedule fires, Kubernetes deletes the active Job (sending SIGTERM to pods) and immediately starts a fresh replacement.

Kubernetes CronJob Concurrency & Timezone Configuration Matrix

Engine / CaseRuntime BehaviorProduction Remediation
concurrencyPolicy: Allow (Default)Starts new Job pods on schedule even when prior runs are still executing.Safe ONLY for completely independent, stateless, fast fan-out tasks; dangerous for DB migrations or ETL.
concurrencyPolicy: ForbidSkips the new scheduled run if the previous Job has not yet completed or failed.Always combine with jobTemplate.spec.activeDeadlineSeconds so one hung pod cannot stall the CronJob indefinitely.
concurrencyPolicy: ReplaceTerminates any currently active Job and creates a new Job at the scheduled tick.Ensure container handles SIGTERM cleanly and performs atomic writes or rollbacks.
.spec.timeZone vs container env TZ.spec.timeZone controls kube-controller-manager trigger times only; pods still default to UTC.Set .spec.timeZone for scheduling AND explicit container TZ env if user-facing reports format local dates.

Edge Cases & Engineering FAQs

What happens if node tzdata inside kube-controller-manager is outdated when a country changes DST laws?

Kubernetes evaluates .spec.timeZone using the timezone database compiled into or mounted by kube-controller-manager on the control plane. Managed clusters (EKS, GKE, AKS) patch control-plane tzdata automatically; self-hosted kubeadm clusters must keep control-plane OS tzdata packages updated.

Why should CronJob pods often use restartPolicy: Never instead of OnFailure?

With restartPolicy: OnFailure, a crashing container restarts in-place on the same node (which may have a full disk or broken CNI) and hides previous container logs once rotated. With restartPolicy: Never and backoffLimit: 2, Kubernetes schedules retry pods onto healthy nodes while preserving failed pod logs up to failedJobsHistoryLimit.

Does Kubernetes CronJob support @hourly, @daily, and @monthly macros?

Yes. robfig/cron in Kubernetes supports standard Vixie macros (@yearly, @monthly, @weekly, @daily, @hourly), mapping @daily to 0 0 * * * in the configured .spec.timeZone.

Runtime Dead-Man's-Switch Verification

Heartbeat & Cron MonitoringBetter Stack →

Dead-man's-switch heartbeat checks that page on-call when a scheduled job skips a DST gap, stalls on a lock, or exits non-zero.