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'm pretty new to AWS and EC2 but I want to run instances with a user script after it's booted from another instance. I have installed ec2 tools and ran the command as it's explained in various examples like here http://www.turnkeylinux.org/blog/ec2-userdata and Eric Hammond's tutorials. however when I actually use the command: "ec2-run-instances --key my-key --user-data-file myscript my-ami" it only runs the new instance but doesn't execute the script myscript contains: #!/bin/bash echo "hello" > ~/output.txt

I'm running ubuntu server 12.04 AMIs. the target AMIs are duplicates of the initiating instance.

if I run curl http:// 169.254.169.254/latest/user-data the imported script is there.

share|improve this question
    
Make sure your sample script is two lines. It won't execute as you have described it in a single line. –  Eric Hammond Oct 1 '12 at 15:06
    
Make sure you are looking for the output in /root as the user data script is run as root. –  Eric Hammond Oct 1 '12 at 15:07
    
Make sure you can execute the sample user data script on an official Ubuntu AMI before you try the same command on your own AMI. –  Eric Hammond Oct 1 '12 at 15:08
    
The script actually DID run and the output was in /root. Thanks Mr. H. –  Bloodnut Oct 2 '12 at 9:41
add comment

1 Answer

up vote 0 down vote accepted

[copying answer from comments to answer entry]

Make sure you are looking for the output in /root as the user data script is run as the root user on first boot.

Other things to consider for others having similar issues:

  • Make sure your sample script is two lines. It won't execute as you have described it in a single line.

  • Make sure you can execute the sample user data script on an official Ubuntu AMI before you try the same command on your own AMI

share|improve this answer
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.