title: Running shell script on instance startup
body: <p>I'm trying to run a bash script when my EC2 instances start up. All I want to do is start up GlassFish when the server starts. The command I'm trying to run is:</p>
  
  <pre><code>sudo /glassfish3/bin/asadmin start-domain
  </code></pre>
  
  <p>Which works when I enter it manually.</p>
  
  <p>I have tried adding this command in a couple places with no luck:</p>
  
  <ul>
  <li>at the end of /etc/rc.local</li>
  <li>at the end of /etc/rc.d/rc.local</li>
  <li>created my own script in /etc/init.d/</li>
  </ul>
  
  <p>I have given every script 777 permissions.</p>
  
  <p>Anyone have any ideas on what I'm doing wrong?</p>