title: ubuntu ec2 - run python script at startup with arguments
body: <p>I have a python script i'd like to start on startup on an ubuntu ec2 instance but im running into troubles.</p>
  
  <p>The script runs in a loop and takes care or exiting when its ready so i shouldn't need to start or stop it after its running. </p>
  
  <p>I've read and tried a lot of approaches with various degrees of success and honestly im confused about whats the best approach. I've tried putting a shell script that starts the python script in /etc/init.d, making it executable and doing update-rc.d to try to get it to run but its failed at every stage. </p>
  
  <p>here's the contents of the script ive tried:</p>
  
  <pre><code>#!/bin/bash
  
  cd ~/Dropbox/Render\ Farm\ 1/appleseed/bin
  while :
  do
      python ./watchfolder18.py -t ./appleseed.cli -u ec2 ../../data/
  done
  </code></pre>
  
  <p>i then did</p>
  
  <pre><code>sudo chmod +x /etc/init.d/script_name
  sudo sudo update-rc.d /etc/init.d/script_name defaults
  </code></pre>
  
  <p>This doesn't seem to run on startup and i cant see why, if i run the command manually it works as expected.</p>
  
  <p>I also tried adding a line to rc.local to start the script but that doesn't seem to work either</p>
  
  <p>Can anybody share what they have found is the simplest way to run a python script in the background with arguments on startup of an ec2 instance. </p>
  
  <p>UPDATE: ----------------------</p>
  
  <p>I've since moved this code to a file called <code>/home/ubuntu/bin/watch_folder_start</code></p>
  
  <pre><code>#!/bin/bash
  
  cd /home/ubuntu/Dropbox/Render\ Farm\ 1/appleseed/bin
  while :
  do
      python ./watchfolder18.py -t ./appleseed.cli -u ec2 ../../data/
  done
  </code></pre>
  
  <p>and changed my <code>rc.local</code> file to this:</p>
  
  <pre><code>nohup /home/ubuntu/bin/watch_folder_start &amp;
  
  exit 0
  </code></pre>
  
  <p>Which works when i manually run rc.local but wont fire on startup, i did <code>chmod +x rc.local</code> but that didn't change anything, </p>