title: Crontab Permission Denied
body: <p>I'm having problem with crontab when I'm running a script.</p>
  
  <p>My <em>sudo crontab -e</em> looks like this:</p>
  
  <pre><code>05 00 * * * /opt/mcserver/backup.sh
  10 00 * * * /opt/mcserver/suspend.sh
  05 08 * * * /sbin/shutdown -r +1
  11 11 * * * /opt/mcserver/start.sh  &lt;--- This isn't working
  </code></pre>
  
  <p>And the <em>start.sh</em> looks like this: </p>
  
  <pre><code>#!/bin/sh
  screen java -d64 -Xincgc -Xmx2048M -jar craftbukkit.jar nogui
  </code></pre>
  
  <p>and have these permissions (ls -l output)</p>
  
  <pre><code>-rwxr-xr-x 1 eve eve  72 Nov 24 14:17 start.sh
  </code></pre>
  
  <p>I can run the command from the terminal, either using sudo or not</p>
  
  <pre><code>./start.sh
  </code></pre>
  
  <p>But it wont start with crontab.
  If i do </p>
  
  <pre><code>grep -iR "start.sh" /var/log
  </code></pre>
  
  <p>I get the following output</p>
  
  <pre><code>/var/log/syslog:Nov 27 11:11:01 eve-desk CRON[5204]: (root) CMD (eve /opt/mcserver/start.sh)
  grep: /var/log/btmp: Permission denied
  grep: /var/log/lightdm/x-0-greeter.log: Permission denied
  grep: /var/log/lightdm/lightdm.log: Permission denied
  grep: /var/log/lightdm/x-0.log: Permission denied
  </code></pre>
  
  <p>So my question is, why isn't it working? 
  And since my script run without using sudo, I don't necessarily need to put it in sudo crontab?</p>
  
  <p><em>( and I'm using Ubuntu 12.10 )</em></p>
  
  <p>Thanks in advance,
  Philip</p>
  
  <p><hr/>
  <em>Answer to twalberg's response</em></p>
  
  <p><strong>1.</strong> Changed owner on craftbukkit to root, to see if that fixed the problem.</p>
  
  <pre><code>-rw-r--r-- 1 root root 12084211 Nov 21 02:14 craftbukkit.jar
  </code></pre>
  
  <p>and also added an explicit cd in my start.sh script as such:</p>
  
  <pre><code>#!/bin/sh
  cd /opt/mcserver/
  screen java -d64 -Xincgc -Xmx2048M -jar craftbukkit.jar nogui
  </code></pre>
  
  <p><strong>2.</strong> I'm not quite sure what you mean here. Should I use the following path in my start.sh file when i start java?
  (<em>output from which java</em>)</p>
  
  <pre><code>/usr/bin/java
  </code></pre>
  
  <p><strong>3.</strong> When my server closes, screen is terminated. Is it a good idea to start screen in "detached mode" anyway?</p>
  
  <p>Still got the same "Permission denied" error. </p>
  
  <hr/>
  
  <p><strong>Problem solved</strong>!
  By using the proper flag on screen, as below, it is now working as it should! </p>
  
  <pre><code>screen -d -m java -d64 -Xincgc -Xmx2048M -jar craftbukkit.jar nogui
  </code></pre>
  
  <p><em>Thanks a lot to those who answered, and especially twalberg!</em></p>