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:
> On Mon, Mar 24, 2008 at 2:44 PM, Dirk Heinrichs <dirk.heinrichs@(protected)>
>
> wrote:
> > Am Montag, 24. März 2008 schrieb Kaushal Shriyan:
> > > MAILTO=systems@(protected)
> > > 0 18 * * * /home/kaushal/rsync_mysql.sh
> > >
> > > I want my subject line to be "hostxx:yyDB refresh daily"
> > >
> > > is there a way to do it
> >
> > Don't rely on cron to send the mail, use mailx inside your script
> > instead. That means, inside the script, capture all output in a temp.
> > file, then use
> >
> > cat /tmp/file|mailx -s "my subject" systems@(protected)
> >
> > HTH...
> >
> >     Dirk
>
> Hi Dirk
>
> Below is my script
> ###########################################################################
>##
>
> #!/bin/bash
> #rsync mysql database shell script
> #author kaushal
> #created on 21/03/2008
>
> TIMESTAMP=`date +%Y-%m-%d-%H:%M:%S:%N`
>
> if rsync -av /var/lib/mysql kaushal@(protected)/
>
> >/tmp/rsync-${TIMESTAMP}.log 2>&1
>
> then
>      echo "Success"
> else
>      echo "Please check the file rsync-${TIMESTAMP}.log for errors."
> fi
>
> ###########################################################################
>##
>
> so according to your suggestion where does this line fits "cat
> /tmp/file|mailx -s "my subject" systems@(protected)>
> in my above bash script
>
> Thanks and Regards
>
> Kaushal

Hmm, if the script is used from cron only, you could reduce it to the
following (note that when run from cron, you may need to use full paths to
your binaries, or set $PATH inside the script):

/usr/bin/rsync -av /var/lib/mysql kaushal@(protected)/
2>&1 |/usr/bin/tee /tmp/rsync-${TIMESTAMP}.log | /usr/bin/mailx -s "My
subject" systems@(protected)

This will mail the output and save it to a file at the same time.

HTH...

 Dirk

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