title: nohup - permission denied
body: <p>I am trying to get a start up script for OrientDB (a database) on Ubuntu to work.</p>
  
  <p>This is currently the line that causes problems:</p>
  
  <pre><code>ORIENTDB_DIR="/usr/local/orientdb"
  ORIENTDB_USER="www-user"
  sudo -u $ORIENTDB_USER sh -c "cd \"$ORIENTDB_DIR/bin\"; /usr/bin/nohup server.sh 1&gt;../log/orientdb.log 2&gt;../log/orientdb.err &amp;"
  </code></pre>
  
  <p>If I start the script, it results in this:</p>
  
  <pre><code>sh: 1: cannot create ../log/orientdb.log: Permission denied
  </code></pre>
  
  <p>Here's the setup:</p>
  
  <ul>
  <li><code>www-user</code> is in the sudoers file</li>
  <li><code>server.sh</code> and any the shell script posted above have execute privileges for root.</li>
  <li>If I change the script to this:
  <code>sudo -u $ORIENTDB_USER sh -c "cd \"$ORIENTDB_DIR/bin\"; /usr/bin/nohup pwd 1&gt;/home/www-user/test.log &amp;"</code>, <code>test.log</code> shows <code>/usr/local/orientdb/bin/</code> as the working directory.</li>
  <li><code>/usr/local/orientdb/log</code> exists but is an empty folder.</li>
  </ul>
  
  <p>Given the above and the fact that I am using <code>sudo</code> to elevate the user, why is permission still denied?</p>