AWS EC2 instance automatically restarts

0

Hi,
On AWS EC2 Ubuntu 20.04 and earlier, I was able to set up a crontab to shut down the instance at night.
0 5 * * * /sbin/shutdown -h now

On Ubuntu 22.04 the server automatically restarts again. Could this be modified so the shutdown command works correctly?

Thanks.

sdarwin
質問済み 1年前372ビュー
2回答
1
承認された回答

The instance may have Auto Recovery set to true. The link shows how to disable this.

I've been able to recreate this behavior on both Ubuntu 20 and 22. Though, I can not recreate it consistently. Seems to happen more often on t2.small vs t3.small. Also, seems to happen more often the first time I issue the sudo shutdown -h now command. But after that first failure, it works as expected. All of this was independent of the Auto Recovery setting. Recommendation at this point is to use the stop-instances API for consistent behavior. See: Instance Scheduler

profile pictureAWS
エキスパート
kentrad
回答済み 1年前
  • Although this idea "The behavior recently changed so mostly likely connected the age of the instance" sounds very plausible and more believable, I have just retested another time, and the results are as follows. A new ubuntu 20 instance can be shutdown from the command line. A new ubuntu 22 instance gets auto restarted.

  • Interesting. I'll give it a try today.

0

@kentrad thanks!
There is still some mystery to it, because I re-verified that on Ubuntu 20 auto recovery didn't need to be adjusted. Not sure what's possible and what's not possible but the ideal behavior would be that a manual shutdown by issuing the shutdown command would stop the instance, and a crash would auto recover. However, if aws can't distinguish the difference between those two conditions, then maybe it has no choice but to reboot both of them.

sdarwin
回答済み 1年前

ログインしていません。 ログイン 回答を投稿する。

優れた回答とは、質問に明確に答え、建設的なフィードバックを提供し、質問者の専門分野におけるスキルの向上を促すものです。

質問に答えるためのガイドライン

関連するコンテンツ