Skip to content

Instantly share code, notes, and snippets.

@lsloan
Created September 10, 2018 17:56
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lsloan/ae9999dbe076129131fda51471546e46 to your computer and use it in GitHub Desktop.
Save lsloan/ae9999dbe076129131fda51471546e46 to your computer and use it in GitHub Desktop.
#!/bin/sh --
# delete pods that have a status of "Completed" or "Error"
oc get pods | tail -n +2 | awk '($3 == "Completed" || $3 == "Error") {print $1}' | xargs -I% -L1 oc delete pod/%
@lsloan
Copy link
Author

lsloan commented Sep 10, 2018

TODO: Learn more about the "-o jsonpath='…'" option to oc to get just the data about completed or error pods. That will eliminate the tail and awk parts of the command.

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