Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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 have a simple shell script that runs Rsync. It runs fine if I call it manually from the command line, but when I set it up as a CRON job I get the following error:

rsync: failed to open exclude file exclude.txt: No such file or directory (2)
rsync error: error in file IO (code 11) at exclude.c(1000) [client=2.6.8]

I use the following in the shell script:

--exclude-from 'exclude.txt'

The file exists and the script runs fine (honoring the exclusions) when run manually. The shell script being called by the CRON job and exclude.txt are in the same directory.

The entire script I'm trying to run looks like this:

rsync -avrhgo --exclude-from 'exclude.txt' --progress --stats --delete-excluded -e "ssh -p XXXXX" / XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
share|improve this question
up vote 3 down vote accepted

You will need to specify the full path to the exclude file, as the working directory of the script will not be automatically the one from where you start the script, but instead the cron job owners home directory.

Alternatively, you can cd into the correct directory from inside your shell script.

share|improve this answer
My hero! Thanks. – binaryorganic Oct 5 '11 at 14:46

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.