Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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: github.com/puppetmodules/puppet-module-tarsnap/blob/master/… –  growse Mar 5 '14 at 12:18

Your Answer


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

Browse other questions tagged or ask your own question.