From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from pigeon.gentoo.org ([69.77.167.62] helo=lists.gentoo.org) by finch.gentoo.org with esmtp (Exim 4.60) (envelope-from ) id 1JdjWf-0001gm-Qi for garchives@archives.gentoo.org; Mon, 24 Mar 2008 10:03:34 +0000 Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 088AAE06D8; Mon, 24 Mar 2008 10:03:31 +0000 (UTC) Received: from wx-out-0506.google.com (wx-out-0506.google.com [66.249.82.228]) by pigeon.gentoo.org (Postfix) with ESMTP id C3B90E06D8 for ; Mon, 24 Mar 2008 10:03:30 +0000 (UTC) Received: by wx-out-0506.google.com with SMTP id h30so2378197wxd.10 for ; Mon, 24 Mar 2008 03:03:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:references; bh=iVA21mgJXqiXoCvTxvgvksrlzmLg6XDb6sSGOiCoLxg=; b=t3p1Ndi2Xxehwo/yclzZTYF6uD5MYORxD8jP7Nrw/bMMX4UaqXOu7mogATWvfV+imY1OIKFXaPdhkvHYXDtvmD1AoCEOxVPBt+/sHOGZVjIm47oehqRFDQ5yxW4gnOR1/nGfl5JMBH0Tkq8XToxo8htoVq9nCwRKGOqDFpEsPcY= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=message-id:date:from:to:subject:in-reply-to:mime-version:content-type:references; b=KYkKgJbyMH60VxkUmUzT+NX5wONkHjqfo6vFhz/EikyuRW3PYpnE20eoq3AT32D2j71dlOYPcHiGs0tC6u46gTBU3JwPJFJd61CG/XaPpG4dYHKlBbx2+1aWiEYMVcu5qG5kJ4xFaYK6GzGTYKrLosidrDypDrx/1NgXZNfQ2Us= Received: by 10.114.158.1 with SMTP id g1mr11179954wae.111.1206353009706; Mon, 24 Mar 2008 03:03:29 -0700 (PDT) Received: by 10.114.120.17 with HTTP; Mon, 24 Mar 2008 03:03:29 -0700 (PDT) Message-ID: <6b16fb4c0803240303k39f430e8n78f1381c84fbde6@mail.gmail.com> Date: Mon, 24 Mar 2008 15:33:29 +0530 From: "Kaushal Shriyan" To: gentoo-user@lists.gentoo.org Subject: Re: [gentoo-user] crontab entry In-Reply-To: <200803241047.58007.dirk.heinrichs@online.de> Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-user@lists.gentoo.org Reply-to: gentoo-user@lists.gentoo.org MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_9231_2948564.1206353009712" References: <6b16fb4c0803240204w227edc7ch894f5cd224ace0be@mail.gmail.com> <200803241014.36432.dirk.heinrichs@online.de> <6b16fb4c0803240232x1189600eofaa35edfb94386fc@mail.gmail.com> <200803241047.58007.dirk.heinrichs@online.de> X-Archives-Salt: 4c19ea5f-fe2a-49e3-a425-4f4fd266326f X-Archives-Hash: ad1823bbbdcec42e1f7d44ad0760eea7 ------=_Part_9231_2948564.1206353009712 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline On Mon, Mar 24, 2008 at 3:17 PM, Dirk Heinrichs wrote: > Am Montag, 24. M=E4rz 2008 schrieb Kaushal Shriyan: > > On Mon, Mar 24, 2008 at 2:44 PM, Dirk Heinrichs < > dirk.heinrichs@online.de> > > > > wrote: > > > Am Montag, 24. M=E4rz 2008 schrieb Kaushal Shriyan: > > > > MAILTO=3Dsystems@webaroo.com > > > > 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@webaroo.com > > > > > > HTH... > > > > > > Dirk > > > > Hi Dirk > > > > Below is my script > > > #########################################################################= ## > >## > > > > #!/bin/bash > > #rsync mysql database shell script > > #author kaushal > > #created on 21/03/2008 > > > > TIMESTAMP=3D`date +%Y-%m-%d-%H:%M:%S:%N` > > > > if rsync -av /var/lib/mysql kaushal@host77:/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" systems@webaroo.com" < > systems@webaroo.com> > > 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 t= o > your binaries, or set $PATH inside the script): > > /usr/bin/rsync -av /var/lib/mysql kaushal@host77:/var/lib/ > 2>&1 |/usr/bin/tee /tmp/rsync-${TIMESTAMP}.log | /usr/bin/mailx -s "My > subject" systems@webaroo.com > > This will mail the output and save it to a file at the same time. > > HTH... > > Dirk > Hi Dirk, Thanks Dirk So the Final script looks like ###########################################################################= ####################################### #!/bin/bash #rsync mysql database shell script #author kaushal #bash script file name rsync_mysql.sh #created on 24/03/2008 TIMESTAMP=3D`date +%Y-%m-%d-%H:%M:%S:%N` if /usr/bin/rsync -av /var/lib/mysql kaushal@host77:/var/lib/ 2>&1 | /usr/bin/tee /tmp/rsync-${TIMESTAMP}.log | /usr/bin/mailx -s "host77 DB refresh daily" kaushal@example.com then echo "Success" else echo "Please check the file rsync-${TIMESTAMP}.log for errors." fi ###########################################################################= ####################################### and the crontab entry would be 0 18 * * * /home/kaushal/rsync_mysql.sh Please let me know if its correct Thanks again Thanks and Regards Kaushal ------=_Part_9231_2948564.1206353009712 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline On Mon, Mar 24, 2008 at 3:17 PM, Dirk Heinrichs <dirk.heinrichs@online.de> wrote:
Am Montag, 24. M=E4rz 2008 schrieb Ka= ushal Shriyan:
> On Mon, Mar 24, 2008 at 2:44 PM, Dirk Heinrichs <dirk.heinrichs@online.de>
>
> wrote:
> > Am Montag, 24. M=E4rz 2008 schrieb Kaushal Shriyan:
> > > MAILTO=3Dsystems@weba= roo.com
> > > 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 sc= ript
> > instead. That means, inside the script, capture all output in a t= emp.
> > file, then use
> >
> > cat /tmp/file|mailx -s "my subject" systems@webaroo.com
> >
> > HTH...
> >
> >        Dirk
>
> Hi Dirk
>
> Below is my script
> ######################################################################= #####
>##
>
> #!/bin/bash
> #rsync mysql database shell script
> #author kaushal
> #created on 21/03/2008
>
> TIMESTAMP=3D`date +%Y-%m-%d-%H:%M:%S:%N`
>
> if rsync -av /var/lib/mysql kaushal@host77:/var/lib/
>
> >/tmp/rsync-${TIMESTAMP}.log 2>&1
>
> then
>         echo "Success"
> else
>         echo "Please check the file rsync-${T= IMESTAMP}.log for errors."
> fi
>
> ######################################################################= #####
>##
>
> so according to your suggestion where does this line fits "cat
> /tmp/file|mailx -s "my subject" systems@webaroo.com" <systems@webaroo.com>
> 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<= br> your binaries, or set $PATH inside the script):

/usr/bin/rsync -av /var/lib/mysql kaushal@host77:/var/lib/
2>&1 |/usr/bin/tee /tmp/rsync-${TIMESTAMP}.log | /usr/bin/mailx -s &= quot;My
subject" systems@webaroo.com

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

HTH...

       Dirk

Hi Dirk,

Thanks Dirk

So the Fin= al script looks like

###############################################= ###################################################################

#!/bin/bash
#rsync mysql database shell script
#author kaushal#bash script file name rsync_mysql.sh
#created on 24/03/2008

TIM= ESTAMP=3D`date +%Y-%m-%d-%H:%M:%S:%N`

if /usr/bin/rsync -av /var/lib= /mysql kaushal@host77:/var/lib/ 2>&1 | /usr/bin/tee /tmp/rsync-${TIM= ESTAMP}.log | /usr/bin/mailx -s "host77 DB refresh daily"
kaushal@example.com

then
        echo "Success&q= uot;
else
        echo "Pleas= e check the file rsync-${TIMESTAMP}.log for errors."
fi

####= ###########################################################################= ###################################

and the crontab entry would be

0 18 * * * /home/kaushal/rsync_my= sql.sh


Please let me know if its correct

Thanks again
=
Thanks and Regards

Kaushal
------=_Part_9231_2948564.1206353009712-- -- gentoo-user@lists.gentoo.org mailing list