From owner-freebsd-questions Sat Oct 6 12:57: 9 2001 Delivered-To: freebsd-questions@freebsd.org Received: from kabel203069.kabel.utwente.nl (kabel203069.kabel.utwente.nl [130.89.203.69]) by hub.freebsd.org (Postfix) with ESMTP id B250037B401 for ; Sat, 6 Oct 2001 12:57:05 -0700 (PDT) Received: by kabel203069.kabel.utwente.nl (Postfix, from userid 1000) id 1A20813670; Sat, 6 Oct 2001 21:57:04 +0200 (CEST) Date: Sat, 6 Oct 2001 21:57:03 +0200 From: Rogier Steehouder To: cyu0635@home.com Cc: "freebsd-questions@FreeBSD.ORG" Subject: Re: [FBSD-Q] script question Message-ID: <20011006215703.A468@localhost> Mail-Followup-To: Rogier Steehouder , cyu0635@home.com, "freebsd-questions@FreeBSD.ORG" References: <3BBF1F7D.3218276B@home.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: <3BBF1F7D.3218276B@home.com>; from cyu0635@home.com on Sat, Oct 06, 2001 at 11:13:02AM -0400 Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG 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