Skip to content

Instantly share code, notes, and snippets.

@murphybytes
Created January 15, 2025 21:26
Show Gist options
  • Save murphybytes/e23e254f9641b5a91ac5f98dd7a25621 to your computer and use it in GitHub Desktop.
Save murphybytes/e23e254f9641b5a91ac5f98dd7a25621 to your computer and use it in GitHub Desktop.
Unsuspend all cronjobs in a namespace
#!/bin/bash
#########################################################################
# Usage: unsuspend-cronjobs.sh <namespace>
# Unsuspends 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" : false }}'
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment