Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我相信当引擎释放资源时谷歌云平台抢占式实例会自动重启,但我错了。
一旦被抢占,实例似乎需要手动重启。
有没有办法在抢占后自动重启实例?
谢谢你。
您可以定期实例化状态并在它终止时重新启动它。假设实例名称instance1和周期为 5 分钟,它将是这样的:
instance1
while true do status=`gcloud compute instances list --filter name=instance1 | tail -1 | awk '{print $NF}'` [[ $status == TERMINATED ]] && gcloud compute instances start instance1 sleep 300 done