Mel wrote:
On Monday 29 December 2008 13:35:06 Noah wrote:
Hi there,
I am trying to figure out the most accurate way to assess if an rsync
process is running and is established to the remote rsync server and is
transferring data. I am writing a bourne shell script to restart rsync
if the connection to the remote rsync server is lost.
The command "ps ax | grep 'rsync' | grep -v grep" is not enough because
the rsync and ssh process can be running but the connection to the
remote server is no longer ESTABLISHED and the backup is no longer
proceeding.
Then perhaps the command "netstat -A | grep '192.168.1.10' | grep
'ESTABLISHED' | grep -v grep" would be helpful. But in some cases I
have found that I have ssh connections to the remote rsync server that
obfuscate the rsync ssh ESTABLISH statistics.
the rsync command I am using is: "/usr/bin/rsync -avz '/Users/noah/' -e
'ssh -p 22' r...@192.168.1.10:/Users"
Any suggestions please?
Set ServerAliveInterval to a low value so the connection is dropped. You can
do this on the commandline using -e 'ssh -o ServerAliveInterval=10 -p 22'.
This would drop the connection if the server can't be reached within 10
seconds.
Once the connection is dropped, rsync should exit with a value other then 0,
so you can wrap your rsync command in a while loop, like:
KEEP_RUNNING=1
while test ${KEEP_RUNNING} -gt 0; do
rsync -avz /Users/noah/ -e 'ssh -p 22 -o ServerAliveInterval=10' \
r...@192.168.1.10:/Users
KEEP_RUNNING=$?
done
I like that - thanks!
_______________________________________________
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "freebsd-questions-unsubscr...@freebsd.org"