Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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.

share|improve this question
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
add comment

1 Answer

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.

share|improve this answer
    
Thanks Matt for the hint. Really it was very helpful for me. –  Shailesh Sutar Jul 3 '13 at 8:27
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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