Created
January 15, 2025 21:22
-
-
Save murphybytes/7c0fafde51c9e95b4cc6b18174031f13 to your computer and use it in GitHub Desktop.
Suspend all cronjobs in namespace
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
######################################################################### | |
# Usage: suspend-cronjobs.sh <namespace> | |
# Suspends cronjobs in a namespace | |
######################################################################### | |
if ! command -v kubectl &> /dev/null | |
then | |
echo "kubectl must be present in order to run this script" | |
exit 1 | |
fi | |
for job in $(kubectl get cj -n "$1" | tail -n +2 | cut -d " " -f 1) | |
do | |
kubectl patch cronjobs "$job" -n "$1" -p '{"spec" : {"suspend" : true }}' | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment