dslreports logo
 
    All Forums Hot Topics Gallery
spc
Search similar:


uniqs
2378

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

Inssomniak

Premium Member

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?

Steve
I know your IP address

join:2001-03-10
Tustin, CA

Steve

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
MVM
join:1999-07-16
Fort Lauderdale, FL

graysonf to Inssomniak

MVM

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

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

Inssomniak to Steve

Premium Member

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.

Maxo
Your tax dollars at work.
Premium Member
join:2002-11-04
Tallahassee, FL

Maxo to Inssomniak

Premium Member

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 Member
join:2005-04-06
Cayuga, ON

Inssomniak

Premium Member

Ok I will try this next time I get in front of the machine. Thx

sempergoofy
Premium Member
join:2001-07-06
Smyrna, GA

sempergoofy to Maxo

Premium Member

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.
 

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

Inssomniak to Steve

Premium Member

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!