Quoting Kaushal Shriyan <[EMAIL PROTECTED]>:

On Fri, Mar 21, 2008 at 12:56 PM, Alan McKinnon <[EMAIL PROTECTED]>
wrote:

On Friday 21 March 2008, Kaushal Shriyan wrote:
> Hi
>
> [EMAIL PROTECTED]
> 0 18 * * * rsync -av /var/lib/mysql [EMAIL PROTECTED]:/var/lib/

Run rsync through a script that tests the exit value, then prints an error message if the exit value is not equal to 0 and nothing otherwise. Run the script from cron and it will send you an e-mail if there is a problem.

In bash, $? is the exit value of the last command. This is a bit verbose, but you could put the following in rsync-host77.sh:

  #!/bin/bash
  TIMESTAMP=`date +%Y-%m-%d-%H:%M:%S:%N`
  rsync -av /bogus [EMAIL PROTECTED]:/bogus/ &>rsync-${TIMESTAMP}.log
  EXITVALUE=$?
  if [[ "${EXITVALUE}" -ne "0" ]]
  then
        echo "Error:  rsync exited with status ${EXITVALUE}"
        echo " "
        echo "Please check the file rsync-${TIMESTAMP}.log for errors."
  fi

To find exit values and their corresponding meanings, search for "EXIT VALUES" in

  http://www.linuxmanpages.com/man1/rsync.1.php

Hope this helps,

-Collin

--
Collin Starkweather, Ph.D.
http://www.linkedin.com/in/collinstarkweather

--
[email protected] mailing list

Reply via email to