远程有序closuresEC2实例?

我正在编写一个脚本,使用ec2-terminate-instances远程closuresEC2实例。 我想执行有序closures(类似于Linux“shutdown”命令触发的closures),而不是简单地closures电源。 这会让我有时间closures正在运行的服务并正确卸载EC2卷。

不幸的是,我无法使用SSHlogin到这些实例,而无需执行大量的额外工作。 有没有简单的方法来触发远程,有序的关机? 或者我需要写一些服务器上的控制守护进程,并且当我想closures服务器的时候,我可以捅一下这个进程?

已经使用API​​停止或终止的EC2实例将被发送适当的命令,这些命令可以被后台驻留程序拦截并用于启动closures。 大多数AMI和默认操作系统已经知道如何获得这些信号。 台式计算机上的电源button发送请求closures的特殊消息也是如此。 API terminate命令不会在实例上“拉上插头”。

看看ec2-stop-instances! 这会立即执行shutdown -h并将实例发送到停止状态,但不会终止实例。 如果要终止实例,请在此之后使用ec2-terminate-instances。

事实certificate, ec2-terminate-instances 确实执行有序closures。 以下是我在远程关机期间在系统上运行tail -f /var/log/messages时看到的内容:

 Apr 11 15:11:40 domU-12-31-39-09-9E-53 shutdown[22770]: shutting down for system halt The system is going down for system halt NOW!9E-53 (Mon Apr 11 15:11:40 2011) Apr 11 15:11:40 domU-12-31-39-09-9E-53 init: Switching to runlevel: 0 Apr 11 15:11:41 domU-12-31-39-09-9E-53 avahi-daemon[988]: Got SIGTERM, quitting. Apr 11 15:11:41 domU-12-31-39-09-9E-53 avahi-daemon[988]: Leaving mDNS multicast group on interface eth0.IPv6 with address fe80::1031:39ff:fe09:9e53. Apr 11 15:11:41 domU-12-31-39-09-9E-53 avahi-daemon[988]: Leaving mDNS multicast group on interface eth0.IPv4 with address 10.210.161.157. Connection to 50.17.174.93 closed by remote host. Connection to 50.17.174.93 closed. 

所以不需要做任何特别的事情 实例将以有序方式closures,并在完成时消失。