在午夜自动重启AWS EC2实例 [英] Auto reboot an AWS EC2 instance at midnight

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

问题描述

我一直在寻找可以在每晚午夜自动重新启动EC2实例的解决方案。



我一直在研究CloudWatch警报如何重新启动EC2实例。实例基于其可用的指标,但不要认为这是正确的路径。



我之所以这样做,是因为随着时间的流逝,我在实例上运行的某些进程无法正确响应,并且该进程似乎在实例重新启动后正确响应。



此刻,我正在手动登录并重新启动例如,但是如果有一种方法可以消除我的可能在某些日子可能会忘记的人工输入,那将非常有帮助。



任何建议都会很多

解决方案

在建议这样做之前,我建议您考虑在该框上设置crontab来重新启动该特定进程,因为与重新启动系统相比,对环境的破坏较小



不过,如果您认为短期内这对您会更好,那么请



进一步阅读




I've been looking at solutions where I can automatically reboot an EC2 instance at midnight everynight.

I've had a look at how CloudWatch alarms can reboot an instance based on the metrics it has available, but don't think that is the right path.

The reason I'm looking to do so is that because over time a certain process I have running on the instance fails to respond correctly and the process seems to respond correctly on an instance reboot.

At the moment I am manually logging in and rebooting the instance but if there was a way to remove my 'human input which could be subject to forgetting on certain days', that would be really helpful.

Any advice would be much appreciated.

解决方案

I would suggest before doing this maybe looking into setting up a crontab on that box for restarting that specific process, as that would be less disruptive to your environment than rebooting the whole instance.

Still, if you've deemed that this would be better for you in the short term, then CloudWatch Events would be a good solution for you. CloudWatch Events are different from the CloudWatch Alerts that you've been looking at thus far, where CW Events allows you to fire events on a wide scope of event patterns defined by actions occurring within AWS services, or arbitrary scheduling patterns.

You can set up a scheduled event to fire at midnight every night (by defining a cron expression), configured with a target that will call EC2 RebootInstances API for a given instance id.

Example configuration from the AWS Console:

Further Reading

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

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