简体   繁体   中英

Stopping then starting EC2 from command line

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.

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

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.)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM