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

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
add comment

1 Answer

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
add comment

Your Answer

 
discard

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.