Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 6 Oct 2001 21:57:03 +0200
From:      Rogier Steehouder <r.j.s@gmx.net>
To:        cyu0635@home.com
Cc:        "freebsd-questions@FreeBSD.ORG" <freebsd-questions@FreeBSD.ORG>
Subject:   Re: [FBSD-Q] script question
Message-ID:  <20011006215703.A468@localhost>
In-Reply-To: <3BBF1F7D.3218276B@home.com>; from cyu0635@home.com on Sat, Oct 06, 2001 at 11:13:02AM -0400
References:  <3BBF1F7D.3218276B@home.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On 06-10-2001 11:13 (-0400), cyu0635@home.com wrote:
> Hi all
> 
> I use the following script to mail to log file
> but sometimes I got the workings 'Null message, hope that ok' after
> running the script
> 
> Why?
> and what is wrong?
> 
> TIA
> 
> #! /bin/bash
> /bin/cat /var/log/messages    > /tmp/tmp_logs
> /bin/cat /var/log/secure    >>  /tmp/tmp_logs
> /bin/cat /tmp/tmp_logs | grep "$(date +"%b %d" | sed 's/ 0/ /g')" | sort
> -o /tmp
> /yesterday_log +2
> /bin/cat /tmp/yesterday_log | mail -s "Yesterday's Logged Events"
> peter@localhos
> t

Suppose your logs rotated this morning, then tmp_logs will not contain
any entries for yesterday, so yesterday_log will be empty and you're
sending an empty mail message. You could adapt this script to include
the latest backup log in tmp_logs using zcat, but even then it would not
be completely full proof (what if yesterdays log entries span several
backups?).

With kind regards, Rogier Steehouder

-- 
                          ___                          _
-O_\                                                  //
 | /               Rogier Steehouder                 //\
/ \                  r.j.s@gmx.net                  //  \
  <---------------------- 25m ---------------------->

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-questions" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20011006215703.A468>