Java Mailing List Archive

http://www.redhatconfig.com/

Home » Gentoo Linux »

Re: [gentoo-user] crontab entry

Dirk Heinrichs

2008-03-24

Replies: Find Java Web Hosting

Author LoginPost Reply
Am Montag, 24. März 2008 schrieb Kaushal Shriyan:

> So the Final script looks like

Is it the final script :-) ?

> #!/bin/bash
> #rsync mysql database shell script
> #author kaushal
> #bash script file name rsync_mysql.sh
> #created on 24/03/2008
>
> TIMESTAMP=`date +%Y-%m-%d-%H:%M:%S:%N`
>
> if /usr/bin/rsync -av /var/lib/mysql kaushal@(protected) |
> /usr/bin/tee /tmp/rsync-${TIMESTAMP}.log | /usr/bin/mailx -s "host77 DB
> refresh daily" kaushal@(protected)
>
> then
>      echo "Success"
> else
>      echo "Please check the file rsync-${TIMESTAMP}.log for errors."
> fi
>
> Please let me know if its correct

There's no need for the if-then-else part anymore. You get the whole output
mailed to the given address. However, if you follow Collins very good
proposal, you could do with:

if /usr/bin/rsync -av /var/lib/mysql kaushal@(protected)/
> /tmp/rsync-${TIMESTAMP}.log 2>&1
then
 subj_prefix="Success"
else
 subj_prefix="Error"
fi
cat /tmp/rsync-${TIMESTAMP}.log| /usr/bin/mailx -s "${subj_prefix}: host77 DB
refresh daily" kaushal@(protected)

So that you can tell from the subject wether the command was succesful or not.

Bye...

 Dirk

Attachment: signature.asc (zipped)
©2008 redhatconfig.com - Jax Systems, LLC, U.S.A.