1 |
Quoting Kaushal Shriyan <kaushalshriyan@×××××.com>: |
2 |
|
3 |
> so according to your suggestion where does this line fits "cat |
4 |
> /tmp/file|mailx -s "my subject" systems@×××××××.com" <systems@×××××××.com> |
5 |
> in my above bash script |
6 |
|
7 |
Dirk gave a lovely one-liner, but my guess is you'll get sick of |
8 |
having to actually check the body of the e-mail to know whether there |
9 |
is a problem, so you could also put the system call to mailx in the |
10 |
if-then-else-fi and indicate in the subject line whether it is a |
11 |
success or failure. |
12 |
|
13 |
Also, you want to cut out the echo or else cron will send an e-mail |
14 |
(remember cron sends an e-mail if there's any output from the |
15 |
command), which is redundant now that you're calling mailx. |
16 |
|
17 |
Finally, note that you left a '>' out of your rsync call. It's fixed below. |
18 |
|
19 |
#!/bin/bash |
20 |
#rsync mysql database shell script |
21 |
#author kaushal |
22 |
#created on 21/03/2008 |
23 |
|
24 |
TIMESTAMP=`date +%Y-%m-%d-%H:%M:%S:%N` |
25 |
|
26 |
if rsync -av /var/lib/mysql kaushal@host77:/var/lib/ \ |
27 |
> /tmp/rsync-${TIMESTAMP}.log 2>&1 |
28 |
then |
29 |
cat /tmp/rsync-${TIMESTAMP}.log | \ |
30 |
mailx -s "Success: hostxx:yyDB refresh daily" <systems@×××××××.com> |
31 |
else |
32 |
cat /tmp/rsync-${TIMESTAMP}.log | \ |
33 |
mailx -s "Error: hostxx:yyDB refresh daily" <systems@×××××××.com> |
34 |
fi |
35 |
|
36 |
Hope this helps, |
37 |
|
38 |
Cheers, |
39 |
|
40 |
-Collin |
41 |
|
42 |
-- |
43 |
Collin Starkweather, Ph.D. |
44 |
http://www.linkedin.com/in/collinstarkweather |
45 |
|
46 |
-- |
47 |
gentoo-user@l.g.o mailing list |