Am Montag, 24. März 2008 schrieb Kaushal Shriyan:
> On Mon, Mar 24, 2008 at 2:44 PM, Dirk Heinrichs <[EMAIL PROTECTED]>
>
> wrote:
> > Am Montag, 24. März 2008 schrieb Kaushal Shriyan:
> > > [EMAIL 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" [EMAIL 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 [EMAIL PROTECTED]:/var/lib/
>
> >/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" [EMAIL PROTECTED]" <[EMAIL 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 [EMAIL PROTECTED]:/var/lib/ 
2>&1 |/usr/bin/tee /tmp/rsync-${TIMESTAMP}.log | /usr/bin/mailx -s "My 
subject" [EMAIL PROTECTED]

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

HTH...

        Dirk

Attachment: signature.asc
Description: This is a digitally signed message part.

Reply via email to