Last active
December 2, 2017 20:56
-
-
Save syoyo/e29580d6f952d30e8042 to your computer and use it in GitHub Desktop.
GCE instance explicit termination
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
gcloud compute instances create ${GCE_MASTER_INSTANCE_NAME} ... | |
# wait instance boot up | |
# fixme: there should be much better way | |
sleep 30 | |
# shutdown after 60 min | |
# must add -f flag(background execution) | |
gcloud compute ssh ${GCE_MASTER_INSTANCE_NAME} --zone ${GCE_ZONE} --ssh-flag="-f" --command="sudo /sbin/shutdown -h -P +60" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Using metadata startup-script looks much better
gcloud compute instances create ${GCE_MASTER_INSTANCE_NAME}
--quiet
--preemptible
--metadata startup-script="nohup sudo /sbin/shutdown -h -P +60 &"
...