up vote 3 down vote favorite
share [g+] share [fb]

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:

++++START+++++++++++++++++++++++++++++++
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:

SHELL=/bin/sh
PATH=/usr/local/bin:/bin:/sbin:/usr/bin:/usr/sbin

#min    hour    mday    month    wday    command
#testing
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+++++++++++++++++++++++++++++++"
date
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-------------------------------"
date
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.

link|improve this question
feedback

1 Answer

up vote 2 down vote accepted

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 ...
link|improve this answer
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
feedback

Your Answer

 
or
required, but never shown

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