LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Server (https://www.linuxquestions.org/questions/linux-server-73/)
-   -   rsync usage (https://www.linuxquestions.org/questions/linux-server-73/rsync-usage-4175455088/)

sagar666 03-22-2013 12:56 AM

rsync usage
 
Hi,

we are having five remote locations.In head office all files will move to one directory called /printing . i want to move these files into five remote locations using rsync and if i use rsync -v -e ssh /printing hubli@192.168.25.11:/printing it transfers only existing files in printing directory, but our users will move the files every five minutes. so i cant execute every time as mentioned above command.so i want to sync automatically every five minutes.please give me procedure to do this .i have one idea using crontab tool i can do this but is der any other idea by using only rsync tool.please help me out

chrism01 03-22-2013 03:36 AM

I'd use cron, as you suggest. Its simpler than setting up rsync in a daemon; you'd be basically re-creating cron functionality.

sagar666 03-23-2013 12:11 AM

But i want use rsync only is it possible??

yzT! 03-23-2013 07:19 AM

5 * * * * "/usr/bin/rsync -v -e ssh /printing hubli@192.168.25.11:/printing"

Don't know if you can add the command like that. If you can't, just write a script whatever.sh with that command within it, and in the crontab line write /path/to/whatever.sh

lleb 03-23-2013 10:31 PM

yzT! has it. put something like that in cron, that is what it is for. you can set it to run every 5min so the first option in cron would be */5 not just 5 as that will run at the 5min mark every hour so 1:05, 2:05, etc... */5 will run every 5min.

you can shorten that as well to */2 or something silly. do keep in mind that if the total amount of files to be pushed across your WAN/LAN takes longer then2-5min then you will run into errors were cron will crash as rsync will still be running and you can only have 1 instance of rsync running at a time.

so create you foo.sh and as you have 5 remote servers to receive the data set the script up to rsync to all 5, one at at time, then just call the script once every five minutes in cron.

Code:

#!/bin/bash
LOG=/path/to/log/file/for/this/script

rsync -aviS /path/to/printing remote_user@remote_IP:/path/to/remote/printing/directory  >> ${LOG}

## do this four more times for each of the remaining remote servers###
exit

then run crontab -e as the user this script will be run under

Code:

*/5    *    *    *    *    /path/to/foo.sh
poof you are fin.


All times are GMT -5. The time now is 04:31 AM.