简体   繁体   English

使用bash或python脚本启动和停止GCE实例

[英]Start and stop GCE instances using bash or python script

I have GCE instance setup and already being used. 我有GCE实例设置,并且已经在使用。 With some services setup and running. 随着一些服务的设置和运行。 I need to be able to stop it and start it with bash or python scripts in a cron job as I won't it to be running only at specific times and days. 我需要能够停止它,并在cron作业中使用bash或python脚本启动它,因为我不会让它仅在特定的时间和日期运行。 Is this possible? 这可能吗? Also would be nice if I could make a snapshot and restore from it. 如果我可以制作快照并从中还原,那也很好。

You use command line ( gcloud tool ) or Google Compute API to start or stop the instances. 您可以使用命令行( gcloud工具 )或Google Compute API来启动或停止实例。 You can implement any of the above method in your script. 您可以在脚本中实现上述任何方法。

Moreover, you can take a look at Preemptible instances which are recently announced. 此外,您可以看一下最近宣布的抢占式实例。 These instances runs on a periodic basis and are very suitable for jobs like batch processing. 这些实例定期运行,非常适合诸如批处理之类的作业。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM