2

I am developing a shell script which actually stops aws running instances in a particular region & start them again as a part of schedule maintenance. but as ec2-api tools are heavy, takes time to execute the ec2 command. I want my system to hold up till the last ec2 command executes entirely and show its O/P. Like if i am executing

ec2-stop-instances some-id --region us-west-1

It should wait for completion of execution of ec2-stop. I didn't find any solution for this hence posting here.

Let me know if any one have any idea about how it should be done.

Shailesh Sutar
  • 1,517
  • 5
  • 23
  • 41
  • 2
    If the script just forks to the background then `wait` will probably do what you're looking for. But I think there some asynchronous magic in the script which isn't going to allow this. – Chris S Jul 02 '13 at 13:06

1 Answers1

4

ec2-stop-instances does not wait for the instance to stop. It only tells AWS to stop instance. It does not wait for the instance to actually stop.

After executing ec2-stop-instances, you will need to execute ec2-describe-instances repeatedly to get the current status and only when the status is 'stopped' would you continue with your script.

Matt Houser
  • 10,053
  • 1
  • 28
  • 28