On Mon, 2008-12-29 at 08:13 -0800, Noah wrote:> 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.
Try the --timeout option, which will make rsync exit if no progress is
made for a specified time period. This is probably easier and more
reliable than coding your own timeout.
> 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.
If you decide to go this route, you can get the pid of the ssh process
holding the connection by passing --program to netstat and then check
whether its parent (for the local ssh) or child (for the remote ssh) is
an rsync process.
--
Matt