Advertisement
fkeles

bulk-delete-instances.sh

May 10th, 2023 (edited)
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.98 KB | Source Code | 0 0
  1. # find and delete running instances with display name like test
  2. for i in $(oci search resource structured-search --query-text "QUERY instance resources where lifeCycleState = 'RUNNING' && displayName =~ 'test' && compartmentId = 'ocid1.compartment.oc1..<compartment-id>' " --query 'data.items[*].identifier' --raw-output|sed 's/\"//g;s/,//g'|egrep -v -e "\[" -e "\]")
  3. do
  4.     time oci compute instance terminate --instance-id "$i" --force
  5. done
  6.  
  7. real    0m1.218s
  8. user    0m0.664s
  9. sys     0m0.060s
  10.  
  11. real    0m1.142s
  12. user    0m0.643s
  13. sys     0m0.050s
  14.  
  15. real    0m1.189s
  16. user    0m0.648s
  17. sys     0m0.050s
  18.  
  19. real    0m1.141s
  20. user    0m0.622s
  21. sys     0m0.050s
  22.  
  23. real    0m1.066s
  24. user    0m0.607s
  25. sys     0m0.062s
  26.  
  27. real    0m1.046s
  28. user    0m0.605s
  29. sys     0m0.072s
  30.  
  31. real    0m0.912s
  32. user    0m0.604s
  33. sys     0m0.059s
  34.  
  35. real    0m1.068s
  36. user    0m0.655s
  37. sys     0m0.069s
  38.  
  39. real    0m1.058s
  40. user    0m0.633s
  41. sys     0m0.060s
  42.  
  43. real    0m0.995s
  44. user    0m0.651s
  45. sys     0m0.050s
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement