title: Ubuntu: Starting a shell script with args at boot
body: <p>I'm running Ubuntu Server 14.04 and I'm trying to get a shell script to run at boot. The problem is the script requires args, one of which is a file (a database) and the other is a port number which is found in the same folder as the script. I'm fairly new to this.</p>
  
  <p>When I go in the folder in terminal for example, I can type:</p>
  
  <pre><code>sh script.sh potato 1234
  </code></pre>
  
  <p>script.sh is the script, potato is the filename, and <strong>1234</strong> is the port number. Works fine when I do it manually.</p>
  
  <p>I tried adding a crontab, @reboot script.sh potato 1234, of course it didn't work, it couldn't find the script.</p>
  
  <p>So I tried:</p>
  
  <pre><code> @reboot */path/to/my/script.sh* potato 1234
  </code></pre>
  
  <p>again, didn't work. Figured it couldn't find the database.</p>
  
  <p>So I tried:</p>
  
  <pre><code>@reboot path/to/my/script.sh /path/to/my/potato 1234
  </code></pre>
  
  <p>Still no dice.</p>
  
  <p>I tried running it in term with paths as well</p>
  
  <pre><code>sh path/to/my/script.sh potato 1234
  </code></pre>
  
  <p>of course failed - the script up and told me it couldn't find the db, as it should.</p>
  
  <p><code>sh /path/to/my/script.sh /path/to/my/potato 1234</code> returned no errors, but it didn't start either.</p>
  
  <p>This is what the script I'm trying to start looks like:</p>
  
  <pre><code>if [ $# -lt 1 -o $# -gt 2 ]; then
      echo 'Usage: restart dbase-prefix [port]'
      exit 1
  fi
  
  if [ ! -r $1.db ]; then
      echo "Unknown database: $1.db"
      exit 1
  fi
  
  if [ -r $1.db.new ]; then
      mv $1.db $1.db.old
      mv $1.db.new $1.db
      rm -f $1.db.old.Z
      compress $1.db.old &amp;
  fi
  
  if [ -f $1.log ]; then
      cat $1.log &gt;&gt; $1.log.old
      rm $1.log
  fi
  
  echo `date`: RESTARTED &gt;&gt; $1.log
  nohup ./moo $1.db $1.db.new $2 &gt;&gt; $1.log 2&gt;&amp;1 &amp;``
  </code></pre>
  
  <p>Any clues?</p>