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 2010-05-30 19:52:50

pheella
New member
Registered: 2010-05-30
Posts: 2

cron and rsync

Hi,
I need a little help. I have NSA210 and I want to make a daily synchronization with another device in network. I have made a simple script to do this. It works fine but there is a problem with cron. When I add the line with this script to crontab, script runs at the right time. It make everything except the rsync command. I have tried to get the line with rsync to the crontab, but the result was the same. And at the output was message that the crontab couldn't find the rsync.
I think that the reason is that busybox which is implemented in ffp is not able to run rsync, but I'm not sure. Any ideas how to solve this problem or make the daily synchronization in another way?
Thanks for response

Here are the scripts a files which I use.

Script to synchronization:

Code:

#!/bin/sh

datum=$(date '+%d_%m_%y')
vystup="/i-data/md0/admin/logs/synchronizace_${datum}"

date >> $vystup
echo >> $vystup

/ffp/bin/rsync -avre ssh --exclude=_Install/ root@192.168.0.8:/mnt/HD_a2/SERVER_SERVIS /i-data/md0/atelier/  >> $vystup 2>/i-data/md0/admin/err1

echo >> $vystup
echo ********************************** >> $vystup

/ffp/bin/rsync -avre ssh --exclude="akce AA&B 2001/" --exclude="akce AA&B 2002/" --exclude="akce AA&B 2003/" --exclude="akce AA&B 2004/" --exclude="akce KPP/" --exclude="akce ARICIA/" root@192.168.0.8:/mnt/HD_a2/SERVER_AKCE /i-data/md0/atelier/  >> $vystup 2>/i-data/md0/admin/err2

echo ********************************** >> $vystup
echo >> $vystup
date >> $vystup
echo Posilam vystup na SERVER >> $vystup
echo *****************KONEC************ >> $vystup

/ffp/bin/rsync -avre ssh $vystup root@192.168.0.8:/mnt/HD_a2/logs >> $vystup 2>/i-data/md0/admin/err3

crontab file:

Code:

# Run ntpdate periodically if users want to sync time from time server
* * * * * /bin/dsrv-mon.sh > /dev/null 2>&1
17 */2 * * * /bin/rbm.sh by_crond > /dev/null 2>&1
#*/10 * * * * /usr/bin/ipcam > /dev/null 2>&1
47 21 * * * /sbin/ntpdate_sync.sh > /dev/null 2>&1
47 9 * * * /sbin/ntpdate_sync.sh > /dev/null 2>&1
0 3 * * * /i-data/md0/admin/synchronizace.sh > /i-data/md0/admin/logs/output.log 2>&1

And the error message from output.log

Code:

/bin/sh: /ffp/bin/rsync: not found

Offline

 

#2 2010-05-31 10:43:20

Mijzelf
Member / Developer
Registered: 2008-07-05
Posts: 709

Re: cron and rsync

This is a firmware cron and a default FFP-stick?

The problem is that FFP is chrooted. So you'll have to chroot your script also.
The command in crontab should be something like:

Code:

/sbin/chroot /mnt/usbstick2 /i-data/md0/admin/synchronizace.sh > /i-data/md0/admin/logs/output.log 2>&1

Futher, your are running an FFP command from  a non-FFP parent, so you'll have to add the ffp binaries to PATH, and to do it properly you should also run the FFP shell. So the header of your script should be:

Code:

#!/ffp/bin/sh

PATH=/ffp/bin:$PATH; export PATH

Offline

 

#3 2010-06-01 21:57:49

pheella
New member
Registered: 2010-05-30
Posts: 2

Re: cron and rsync

Well, thank you very much for your help. Now it works perfectly :-) I just had a little problem with mounting directories to chroot mode, but mount --bind solved it fine.
I have also edited the script for running the FFP shell.
Once again thank you

Offline

 

Board footer

Powered by PunBB
© Copyright 2002–2010 PunBB