我已经在Amazon WebServices中触发了EC2实例。我也已经在/etc/init.d文件夹中创建了一个服务,它叫做shutdownSocketServer,我希望它在关闭和重启时被调用。
我已经将它添加到chkconfig -add中,并且我检查了它的定义
sudo chkconfig --list | grep shutdownSocketServer shutdownSocketServer 0:on 1:off 2:off 3:off 4:off 5:off 6:on The script is : #/bin/bash # chkconfig: 06 001 001 # description: Foo server . /etc/init.d/functions sudo touch /var/lock/subsys/shutdownSocketServer start(){ EC2_INSTANCE_ID="`wget -q -O - http://169.254.169.254/latest/meta-data/instance-id || die \"wget instance-id has failed: $?\"`" echo "$EC2_INSTANCE_ID" curl "http://mywebservice.com/Server/functions/SocketUpdater.php? estado=shutdown&instance_id=$EC2_INSTANCE_ID" } stop(){ echo "stopping" } ### main logic ### case "$1" in start) start ;; stop) stop ;; status) status ;; restart|reload|condrestart) stop start ;; *) echo $"Usage: $0 {start|stop|restart|reload|status}" exit 1 esac exit 0
所以我的问题是我认为EC2关闭时无法访问网络。如何避免这种情况?我不确定,该如何检查?由于我不是Bash专家,因此非常感谢您提供一些答案的代码。提前致谢