Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

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

Right now I have a setup with a load balancer that starts new instances of a server (debian) if needed be on the Amazon EC2 cloud. On this setup I have a script that needs to be running on only one of these servers.

Having multiple snapshots could very easily end up being a pain when it comes to updating the system, so my question is how would I go about making a startup script that only runs on the first of the servers?

Is it possible to pull information from Amazon from the command line that could be used to determine this?

share|improve this question
up vote 1 down vote accepted

Use the user-data then check the user-data as part of your start-up. Either run or don't run your script based on the contents of the user-data.

The user data can be set as part of the launch wizard in the AWS Management Console, or from the command line tools.

You can read the user-data from

Full details about EC2 instance metadata can be found at

share|improve this answer

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.