自行终止的AWS EC2实例? [英] Self-Terminating AWS EC2 Instance?

查看:739
本文介绍了自行终止的AWS EC2实例?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有一种方式,亚马逊网络服务EC2实例可自行终止?亚马逊是否有任何允许实例在运行多说,一个小时后自行终止(切腹)?我可以改变脚本的运行实例来做到这一点本身,但可能会失败,我不想要编辑的图像,所以我想亚马逊杀实例。

Is there a way that Amazon Web Services EC2 instances can be self terminating? Does Amazon have anything that allows an instance to terminate itself ("Hara-Kiri") after running for more than say an hour? I could change the scripts on the running instance to do this itself, but that might fail and I don't want to edit the image, so I would like Amazon to kill the instance.

推荐答案

有一个实例终止自己做这两个步骤:

To have an instance terminate itself do both of these steps:

  1. 与--instance启动关机 - 行为终止或在AWS控制台或API调用等效启动实例。

  1. Start the instance with "--instance-initiated-shutdown-behavior terminate" or the equivalent on the AWS console or API call.

运行关机现在-h为根。在Ubuntu上,你可以设置此使用的情况发生在55分钟内:

Run "shutdown -h now" as root. On Ubuntu, you could set this up to happen in 55 minutes using:

回声命令叫停|在现在+ 55分

echo "sudo halt" | at now + 55 minutes

我写了一篇文章而回的其它选项来完成此相同的终止于一小时的目标:

I wrote an article a while back on other options to accomplish this same "terminate in an hour" goal:

在Amazon EC2上
自动终止临时实例   <一href="http://alestic.com/2010/09/ec2-instance-termination">http://alestic.com/2010/09/ec2-instance-termination

Automatic Termination of Temporary Instances on Amazon EC2
http://alestic.com/2010/09/ec2-instance-termination

这篇文章最初是前实例启动,关机,行为可用,但你会发现更新和其他宝石的意见。

The article was originally written before instance-initiated-shutdown-behavior was available, but you'll find updates and other gems in the comments.

这篇关于自行终止的AWS EC2实例?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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