是否可以按计划启动和停止Google Compute实例? [英] Can Google Compute instances be started and stopped on a schedule?

查看:84
本文介绍了是否可以按计划启动和停止Google Compute实例?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我每天从台式计算机运行一次简单的任务3次.它在下午4点,晚上8点和凌晨1点连接到某个网站,下载少量数据(小于50mb),并将其存储在硬盘上.此操作每天都非常重要,因此我正在考虑将其移至Google Compute.我知道我可以创建一个实例并将其保留在24/7/365上,但这很昂贵.有没有办法让实例仅在下午4点,晚上8点和凌晨1点分别打开10分钟,以便可以下载数据,然后在之后关闭它们,所以我每天只需要支付30分钟的Google Compute时间?顺便说一句,如果相关的话,我会使用Windows Server 2008映像(我相信Google Compute现在只能在有限的预览中使用),而不是Linux映像.

I run a simple task 3 times a day from my desktop computer. It connects to a certain website at 4pm, 8pm, and 1am, downloads a small amount of data (less then 50mb), and stores it on the harddrive. It's important that this runs everyday, so I am looking into moving this to Google Compute. I know I could just create an instance and leave it on 24/7/365, but that is expensive. Is there a way to have the instance turn on only at 4pm, 8pm, and 1am for 10 minutes each so the data can be downloaded, and then have them turn off after, so I am only charged 30 minutes/day of Google Compute time? Btw, I would be using a Windows Server 2008 image (which is now in limited preview at Google Compute I believe), not a linux image, in case that is relevant.

推荐答案

Compute Engine实例没有内置的调度程序.

There is not a built in scheduler for Compute Engine instances.

您可以使用App Engine的cron计划程序进行Compute Engine API调用.这是一个示例应用程序,它使用cron来列出实例并删除已运行8小时以上的实例.

You can use App Engine's cron scheduler to make Compute Engine API calls. Here is a sample app which uses cron to list instances and delete ones which have been running for more than 8 hours.

您可以执行类似的操作,方法是创建一个App Engine网址,该网址会使用运行您的任务的启动脚本来启动实例,然后将数据复制到Cloud Storage,然后在实例完成后立即将其关闭.然后,创建cron作业以按您的计划访问该URL.

You could do something similar, by making an App Engine url which starts an instance with a startup script which runs your task, copies the data to Cloud Storage and then shuts down the instance as soon as it is complete. Then, create the cron job to hit that URL on your schedule.

这篇关于是否可以按计划启动和停止Google Compute实例?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆