Java Mailing List Archive

http://www.redhatconfig.com/

Home » Gentoo Linux »

Re: [gentoo-user] rsync script

Collin Starkweather

2008-03-21

Replies: Find Java Web Hosting

Author LoginPost Reply
Quoting Kaushal Shriyan <kaushalshriyan@(protected)>:

> On Fri, Mar 21, 2008 at 12:56 PM, Alan McKinnon <alan.mckinnon@(protected)>
> wrote:
>
>> On Friday 21 March 2008, Kaushal Shriyan wrote:
>> > Hi
>> >
>> > MAILTO=kaushal@(protected)
>> > 0 18 * * * rsync -av /var/lib/mysql kaushal@(protected)/

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 foo@(protected)
 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

--
gentoo-user@(protected)

©2008 redhatconfig.com - Jax Systems, LLC, U.S.A.