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
# install parallel first (sudo apt-get install -y parallel) | |
JOB_NUM=10 | |
NAME_FILTER='*' | |
# stop instances | |
gcloud compute instances list --filter=name:$NAME_FILTER | awk '/RUNNING/ {printf "gcloud -q compute instances stop %s --zone %s;\n", $1, $2 > "stop-instances.txt" }' | |
parallel --jobs $JOB_NUM < stop-instances.txt | |
# remove delete protection |