Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have been experimenting around with ec2-describe-instances and ec2-describe-instance-status in the EC2 command line tools with the goal of starting stopped instances. However I cannot neatly list all stopped instances. ec2-describe-instance-status only lists running instances (unless I am doing something wrong).

Is there an easier way to list stopped instances than awk-ing the hell out of ec2-describe-instances?

share|improve this question
up vote 4 down vote accepted

Use the following command to list the stopped instances.

ec2-describe-instances --filter "instance-state-name=stopped"

share|improve this answer
Excellent! That's half the battle won! Having that pre-filter will make awk-ing the output easier anyway. Cheers for that! – Oldtowner Sep 12 '12 at 8:14

You can use a ruby script I've written for some purposes that uses the aws gem:


require 'aws'

ec2 =
:access_key_id => 'AWS_KEY',
:secret_access_key => 'AWS_SECRET')

ec2.regions.each do |region|
 ec2.regions["#{}"].instances.each do |line|
  if line.status.to_s=="stopped"
   puts("#{line}") #check docs for what exactly you need to output

You can modify it for your own purposes to get all the data you need. Just check the docs at (if I'm not wrong).

share|improve this answer
I would prefer if there was a stand alone solution that doesn't require additional libraries. Also, I'm not immediately familiar with Ruby, so that is another layer removed! Cheers for the link though, I now have a fall back :D – Oldtowner Sep 11 '12 at 16:58

ec2-describe-instances --filter "instance-state-name=stopped" | ec2-start-instances -

The "-" tells ec2-start-instances to read from stdin.

share|improve this answer

ec2-describe-instance-status --filter "instance-state-name=stopped"

This will only provide youlist of stopped instances.

share|improve this answer
This maybe something about my setup that needs debugging, but ec2-describe-instance-status only lists running instances. Is this right? should it list stopped instances? – Oldtowner Sep 11 '12 at 16:49
no, it also lists stopped instances as well. try this command and see yourself – Farhan Sep 11 '12 at 16:50
I have run the command, and as I say, stopped instances are not listed, it does list all running though. With the filtered argument, nothing is returned. – Oldtowner Sep 11 '12 at 16:54
ec2-describe-instance-status only lists instances in the "Running" state. See… – Matt Houser Sep 11 '12 at 17:22
Try ec2-describe-instances --filter "instance-state-name=stopped" – Matt Houser Sep 11 '12 at 17:23

Your Answer


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.