Gentoo Archives: gentoo-user

From: Dirk Heinrichs <dirk.heinrichs@××××××.de>
To: gentoo-user@l.g.o
Subject: Re: [gentoo-user] crontab entry
Date: Mon, 24 Mar 2008 09:48:16
Message-Id: 200803241047.58007.dirk.heinrichs@online.de
In Reply to: Re: [gentoo-user] crontab entry by Kaushal Shriyan
1 Am Montag, 24. März 2008 schrieb Kaushal Shriyan:
2 > On Mon, Mar 24, 2008 at 2:44 PM, Dirk Heinrichs <dirk.heinrichs@××××××.de>
3 >
4 > wrote:
5 > > Am Montag, 24. März 2008 schrieb Kaushal Shriyan:
6 > > > MAILTO=systems@×××××××.com
7 > > > 0 18 * * * /home/kaushal/rsync_mysql.sh
8 > > >
9 > > > I want my subject line to be "hostxx:yyDB refresh daily"
10 > > >
11 > > > is there a way to do it
12 > >
13 > > Don't rely on cron to send the mail, use mailx inside your script
14 > > instead. That means, inside the script, capture all output in a temp.
15 > > file, then use
16 > >
17 > > cat /tmp/file|mailx -s "my subject" systems@×××××××.com
18 > >
19 > > HTH...
20 > >
21 > > Dirk
22 >
23 > Hi Dirk
24 >
25 > Below is my script
26 > ###########################################################################
27 >##
28 >
29 > #!/bin/bash
30 > #rsync mysql database shell script
31 > #author kaushal
32 > #created on 21/03/2008
33 >
34 > TIMESTAMP=`date +%Y-%m-%d-%H:%M:%S:%N`
35 >
36 > if rsync -av /var/lib/mysql kaushal@host77:/var/lib/
37 >
38 > >/tmp/rsync-${TIMESTAMP}.log 2>&1
39 >
40 > then
41 > echo "Success"
42 > else
43 > echo "Please check the file rsync-${TIMESTAMP}.log for errors."
44 > fi
45 >
46 > ###########################################################################
47 >##
48 >
49 > so according to your suggestion where does this line fits "cat
50 > /tmp/file|mailx -s "my subject" systems@×××××××.com" <systems@×××××××.com>
51 > in my above bash script
52 >
53 > Thanks and Regards
54 >
55 > Kaushal
56
57 Hmm, if the script is used from cron only, you could reduce it to the
58 following (note that when run from cron, you may need to use full paths to
59 your binaries, or set $PATH inside the script):
60
61 /usr/bin/rsync -av /var/lib/mysql kaushal@host77:/var/lib/
62 2>&1 |/usr/bin/tee /tmp/rsync-${TIMESTAMP}.log | /usr/bin/mailx -s "My
63 subject" systems@×××××××.com
64
65 This will mail the output and save it to a file at the same time.
66
67 HTH...
68
69 Dirk

Attachments

File name MIME type
signature.asc application/pgp-signature

Replies

Subject Author
Re: [gentoo-user] crontab entry Kaushal Shriyan <kaushalshriyan@×××××.com>