This is a tricky one:

I have a cron job that runs a script with lots of rsync commands in it. For some reason after I added the --max-size=2G parameter to each rsync command the job errors out with the following:

Tue Mar  9 16:53:00 EST 2010
rsync: --max-size=2G: unknown option
rsync error: syntax or usage error (code 1) at main.c(1023)

real    0m0.018s
user    0m0.011s
sys    0m0.006s
----END FONTS-------------------------------
Tue Mar  9 16:53:00 EST 2010

Here's my cron:


#min    hour    mday    month    wday    command
53 16 * * 2 /Users/admin/Documents/scripts/test_rsync_script > /Users/admin/Documents/logs/$(date +\%y_\%m_\%d__\%H_\%M).log 2>&1

Here's the content of test_rsync_script (I obfuscated the IP address for this post:

echo "++++START+++++++++++++++++++++++++++++++"
time rsync --max-size=2G --archive --verbose --update -e ssh /Volumes/RAID/FONTS/ root@xxx.xxx.xxx.xxx:/Volumes/OFFSITE/FONTS --delete 
echo "----END FONTS-------------------------------"
echo "--------------------------------------"

I've tested the cron command as root on the command line and all is well! Is there something wrong with my cron? It works fine if the --max-size=2G parameter is not there.


You may have two different versions of rsync. The $PATH is different in cron than at the command line.

Try type -a rsync to show the locations of the executables. Then use the full path designation to the correct version in your script.

/path/to/rsync rsync_options ...
  • That was totally it! Thank you. When I used that command as root I actually had two rsync's. /usr/local/bin/rsync : didn't support --max-size flag, /usr/bin/rsyn : did support it – milesmeow Mar 10 '10 at 15:33

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.