DSM-G600, DNS-3xx and NSA-220 Hack Forum

Unfortunately no one can be told what fun_plug is - you have to see it for yourself.

You are not logged in.

Announcement

#1 2009-05-06 13:07:35

iazmin
Member
Registered: 2008-09-10
Posts: 55

crontab rysnc don't work

I am running ffp from my usb stick and I want to backup the whole ffp back to mnt/HD_a2/ffp every 1600 (4pm everyday) so that in case I want to remove the ffp stick, I still can run ffp with the same config from the HDD.

The following is my crontab.sh in ffp/start (in the usb).

Code:

#!/bin/sh

CRONTEXT=/mnt/HD_a2/crontab.txt

#start with existing crontab
/bin/crontab -l > $CRONTEXT

#add backup job for ffp at 03:00 o'clock on Saturday
/bin/echo "00 16 * * * /ffp/bin/rsync -av --delete /mnt/usb/ffp
/mnt/HD_a2/ffp" >> $CRONTEXT

#install new crontab
/bin/crontab $CRONTEXT

#clean up
/bin/rm $CRONTEXT

I add the command to run the crontab.sh in fun_plug.local since it just wouldn't run automatically after reboot. I just add the following in fun_plug.local:

Code:

chmod a+x /ffp/start/crontab.sh
/ffp/start/crontab.sh

The rysnc now is added into crontab from my crontab -l command:

Code:

root@nashawa:/mnt/usb/ffp/home/root# crontab -l
*/10 * * * * /usr/sbin/offl_chk two &
*/60 * * * * /usr/sbin/getdhcp&
00 16 * * * /ffp/bin/rsync -av --delete /mnt/usb/ffp
/mnt/HD_a2/ffp

Further check with the clock also shows, the clock is properly synchronize:

Code:

root@nashawa:/mnt/usb/ffp/home/root# date
Wed May  6 17:50:03 SGT 2009

however, when I compare the ffp in usb with the ffp in HDD, it just doesn't work. I am confused now, where is the problem. If I run the rsync manually it will work successfully.

Offline

 

#2 2009-05-06 20:48:39

talkingRock
Member
Registered: 2009-03-26
Posts: 100

Re: crontab rysnc don't work

First, I assume that the newline in the command line is an artifact of how you cut and paste, not really in the script.

Second,

date probably resolves to /ffp/bin/date

crond cares about what /bin/date says.
The two different versions process time zones differently and take their timezones separately.

What does /bin/date say?

Offline

 

#3 2009-05-07 16:00:11

iazmin
Member
Registered: 2008-09-10
Posts: 55

Re: crontab rysnc don't work

talkingRock wrote:

First, I assume that the newline in the command line is an artifact of how you cut and paste, not really in the script.

At last it works!

2 errors. The 1st one, as talkingRock mentioned, my newline in the command line for /ffp/bin/rsync -av --delete /mnt/usb/ffp /mnt/HD_a2/ffp in due to my cut and paste directly from Windows which is not in  UNIX newline (LF). I corrected it using Notepad++ and solved that.

Secondly, it simply because I missed the * after the my /mnt/usb/ffp which mean no file is copied form the source at all. So my final working crontab.sh looks like this:

Code:

#!/bin/sh

CRONTEXT=/mnt/HD_a2/crontab.txt

#start with existing crontab
/bin/crontab -l > $CRONTEXT

#add backup job for ffp at 03:00 o'clock on Saturday
/bin/echo "00 19 * * * /ffp/bin/rsync -av --delete /mnt/usb/ffp/* /mnt/HD_a2/ffp"$

#install new crontab
/bin/crontab $CRONTEXT

#clean up
/bin/rm $CRONTEXT

Thank you talkingRock for noting my error.

Offline

 

Board footer

Powered by PunBB
© Copyright 2002–2010 PunBB