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.

  • 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 2 '13 at 13:06
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.

  • Thanks Matt for the hint. Really it was very helpful for me. – Shailesh Sutar Jul 3 '13 at 8:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.