Skip to content

Instantly share code, notes, and snippets.

@mousavian
Last active September 15, 2023 08:40
Show Gist options
  • Save mousavian/1541a6a38c2a8db0e9a95f5944946270 to your computer and use it in GitHub Desktop.
Save mousavian/1541a6a38c2a8db0e9a95f5944946270 to your computer and use it in GitHub Desktop.
Suspending all cronjobs in all namespaces in kubernetes
#!/bin/bash
for ns in $(kubectl get ns -o jsonpath="{.items[*].metadata.name}"); do
for cj in $(kubectl get cronjobs -n "$ns" -o name); do
kubectl patch "$cj" -n "$ns" -p '{"spec" : {"suspend" : true }}';
done
done
@KozhevnikovM
Copy link

Nice! Thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment