3

I'm trying to stop and then immediately start (NOT REBOOT) my Amazon EC2 server from within my instance

I have CLI (Command Line Interface Tools) and am running a Windows 2012 server.

Basically, I want to ec2-stop-instances from a batch, and then ec2-start-instances right after. But I want the start-instances to run after a minute or so.

Is there a way to send the command and ask Amazon to wait a minute before it is run?

This way, running the batch script will stop then start the instance.

Again, I can't use reboot. For some reason, it does not work with my needs.

Quelklef
  • 1,999
  • 2
  • 22
  • 37

2 Answers2

3

I understand this post is 3 years old, but it is possible to do this now with the AWS CLI, https://docs.aws.amazon.com/cli/latest/reference/ec2/stop-instances.html

aws ec2 stop-instances --instance-ids

aws ec2 start-instances --instance-ids

This could also be done from a Lambda Function, and scheduled

Community
  • 1
  • 1
Max
  • 54
  • 3
0

So what you need to do is to schedule running a command with AWS API

And it's currently not possible to do it so because AWS API lack this feature.

So you cannot achieve what you described without another EC2 instance/other server/service, to scheduling running the command with something cron-like.

(But perhaps it will be possible soon - see this answer for info about it.)

Community
  • 1
  • 1
Greg Dubicki
  • 5,983
  • 3
  • 55
  • 68