0

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
3

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.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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