Skip to content

Instantly share code, notes, and snippets.

@knil-sama
Last active July 15, 2019 09:11
Show Gist options
  • Save knil-sama/5bf73a509a69c21601703b70e1cec105 to your computer and use it in GitHub Desktop.
Save knil-sama/5bf73a509a69c21601703b70e1cec105 to your computer and use it in GitHub Desktop.
kubectl get job -o json | jq --arg DATE "$(date '+%s' -d '1 day ago')" '.items[] | select(.metadata.creationTimestamp | fromdateiso8601 < $DATE) | .metadata.labels."job-name" | select(.!=null) '
@knil-sama
Copy link
Author

knil-sama commented Jul 15, 2019

kubectl get job -o json | jq --arg DATE "$(date '+%s' -d '1 day ago')" '.items[] | select(.metadata.creationTimestamp | fromdateiso8601 <= $DATE) | .metadata.labels."job-name" | select(.!=null) ' | xargs kubectl delete job

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