Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I've got a cron job in root's crontab defined like this:

0 1 * * * /usr/local/bin/tarsnap-backup-script > /tmp/tarsnapcron.txt 2> /tmp/tarsnapcron.err

The script is a python script that executes tarsnap, which reads the key from /root/tarsnap.key. This key is owned by root and chmod 400.

If I run the script from the bash shell, it executes without error. However, under cron, I get a python exception printed to tarsnapcron.err:

could not change directory to "/root": Permission denied

What's the difference between running this script as root in bash, and running it from root's crontab? Why can the latter not read from /root?

share|improve this question
Is it a setuid script? Did you check your audit log? – Michael Hampton Mar 5 '14 at 12:02
What's the script ? – Iain Mar 5 '14 at 12:02
@MichaelHampton script doesn't call setuid. Which audit log do you mean? Script is from the puppet tarsnap module, script template is here:… – growse Mar 5 '14 at 12:18

I had the same problem and the solution was, to grant root group rights:

chmod 440 /root/backup.key

After that cron was able to read the file, and the backup script run flawlessly.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.