Skip to main content

How to temporarily suspend a Kubernetes CronJob

·1 min

You need to stop a CronJob from firing - maybe it’s paging you at 3am while you fix the root cause, maybe you’re running a manual backfill and don’t want the scheduled one to race you. You don’t want to delete the CronJob because then you’d have to remember to re-create it, and you’d lose the last-run history.

The Command #

kubectl patch cronjob my-cronjob -p '{"spec":{"suspend":true}}'

The CronJob still exists, its history is intact, but it stops scheduling new jobs.

Resume It #

kubectl patch cronjob my-cronjob -p '{"spec":{"suspend":false}}'

Check the Status #

kubectl get cronjob my-cronjob -o jsonpath='{.spec.suspend}'

Returns true or false.

What Happens to Running Jobs #

Suspending only stops future scheduling. Any Job already spawned by the CronJob will keep running to completion. If you also want to kill in-flight work:

kubectl delete jobs -l job-name=my-cronjob-<timestamp>

Namespaced Version #

If your CronJob isn’t in the default namespace, add -n:

kubectl patch cronjob my-cronjob -n batch -p '{"spec":{"suspend":true}}'

Why Not Just Delete? #

You can, but you’d lose:

  • The last-scheduled and last-successful timestamps
  • The Job history (if you rely on it for auditing)
  • The exact schedule (if it isn’t stored in Git)

Suspending is the reversible move. Deleting is the “I know what I’m doing” move.

Mateusz Soltysik
Author
Mateusz Soltysik
Senior Software Engineer & Tech Lead | Python • Go • TS | Certified AWS & GCP Architect