dslreports logo
site
 
    All Forums Hot Topics Gallery
spc

spacer




how-to block ads


Search Topic:
uniqs
1553
share rss forum feed


Inssomniak
The Glitch
Premium
join:2005-04-06
Cayuga, ON
kudos:2

rsync works ok at prompt but not in crontab.

I have an rsync command refined to my needs that works perfectly at the prompt, but will not run properly in crontab. It seems to ignore all the --excludes..

here is the command

52  9    * * *   root    rsync -aAXvu --delete --log-file=/root/rsync.log  /* root@10.40.36.143:/mnt/backups/backups/ns1.xxxxxx.ca --exclude={/dev/*,/proc/*,/sys/*,/tmp/*,/run/*,/mnt/*,/media/*,/lost+found} >/dev/null 2>&1
 

I thought it would be the { brackets, but it fails with single and double quotes as well.
Any ideas?

--
OptionsDSL Wireless Internet
»www.optionsdsl.ca


Steve
I know your IP address
Consultant
join:2001-03-10
Foothill Ranch, CA
kudos:5

First: don't run rsync directly from cron; these command lines are too long and hard to document.

Instead, put it in a shell script (say, /usr/local/bin/cron-rsync-to-some-other-machine) and then run this out of cron.

52 9 * * * /usr/local/bin/cron-rsync-to-some-other-machine
 
The --exclude stuff for sure has to be in single quotes.

Are you seeing anything in the logs?


graysonf
Premium,MVM
join:1999-07-16
Fort Lauderdale, FL
kudos:2
reply to Inssomniak

Have you tried without '>/dev/null 2>&1' and then looking in the cron log for any problems?



Inssomniak
The Glitch
Premium
join:2005-04-06
Cayuga, ON
kudos:2
reply to Steve

Yea in the logs I can see it try to sync the /proc directory and fails with some error about file disappearing. And when I run ps aux I can see the command rsync received and it is trying to sync all the excluded directories.
--
OptionsDSL Wireless Internet
»www.optionsdsl.ca



Maxo
Your tax dollars at work.
Premium,VIP
join:2002-11-04
Tallahassee, FL
reply to Inssomniak

Two things.
1. crontab does not source .profile or related scripts automatically.
2. When testing at the prompt, are you using the same shell that crontab is using?
Do what Steve See Profile says and include the proper shell header on the first line of your script.



Inssomniak
The Glitch
Premium
join:2005-04-06
Cayuga, ON
kudos:2

Ok I will try this next time I get in front of the machine. Thx
--
OptionsDSL Wireless Internet
»www.optionsdsl.ca



sempergoofy
Premium
join:2001-07-06
Smyrna, GA
Reviews:
·AT&T Southeast
reply to Maxo

said by Maxo:

Two things.
1. crontab does not source .profile or related scripts automatically.
2. When testing at the prompt, are you using the same shell that crontab is using?
Do what Steve See Profile says and include the proper shell header on the first line of your script.

+1 to this explanation.

On opensuse, I always do this in my crontabs:
SHELL=/bin/bash
# The opensuse default path for cron jobs contains only "/usr/bin:/bin"
PATH=/sbin:/usr/sbin:/usr/local/sbin:/usr/local/bin:/usr/bin:/bin
# crontab entries begin here.
 

--
nohup rm -fr /&


Inssomniak
The Glitch
Premium
join:2005-04-06
Cayuga, ON
kudos:2
reply to Steve

It worked ok running it from its own script called by cron but it still didnt like the single quotes, the excludes still had to be in the {} brackets.

Thanks for the help!
--
OptionsDSL Wireless Internet
»www.optionsdsl.ca