From owner-freebsd-questions@FreeBSD.ORG Fri Jun 18 12:43:24 2004 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id A90DC16A4CE for ; Fri, 18 Jun 2004 12:43:24 +0000 (GMT) Received: from fbsd03.granitepost.com (fbsd03.granitepost.com [209.150.104.133]) by mx1.FreeBSD.org (Postfix) with ESMTP id 5227F43D2F for ; Fri, 18 Jun 2004 12:43:23 +0000 (GMT) (envelope-from clabrown@granitepost.com) Received: from SAGER (thunder.granitepost.com [209.150.104.140]) by fbsd03.granitepost.com (Postfix) with ESMTP id 609C520CDE for ; Fri, 18 Jun 2004 08:42:45 -0400 (EDT) Message-ID: <002301c45531$bff772c0$8c6896d1@SAGER> From: "Clarence Brown" To: Date: Fri, 18 Jun 2004 08:42:42 -0400 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2800.1409 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1409 Subject: how to processi log files before rotation. X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list Reply-To: Clarence Brown List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 18 Jun 2004 12:43:24 -0000 2 questions ... 1. Where is the "right", or "standard" place to save shell scripts that I want to use for administrative, or any other tasks. Some place on the path I suppose. 2. I'd like to process my maillog and maillog.*.gz files just before the maillog it is rotated into maillog.1.gz and maillog.7.gz is discarded. I've written a couple of simple scripts to process the files and report the number total number of messages blocked with the DNSBL filters for today and the last 7 days, as well as the numbers for each of the DNSBL lists that I use. It also processes the maillog file and produces a total number blocked for each user and emails that and a list of the messages blocked to that user so that the user can check to make sure that they are not missing "good" email. I'd like to schedule the DNSBL status scripts to run every night just before the maillog rotation happens. I've found where in the /etc/crontab the log file rotation is scheduled, but I don't know if there is a way to ensure that my status scripts start, and run to completion before the logfile rotation starts. As a test I added a couple of lines to run every 2 minutes to see what order they executed in and found that the order of the lines in crontab doesn't guarantee order of execution ... or at least completion of the commands. The commands I added were more or less as follows: */2 * * * * root /root/dnsblstat */2 * * * * root mail -s "test line 1" my_email_addr */2 * * * * root mail -s "test line 2" my_email_addr What I found was that the dnsblstat never completed before the two following email commands, and sometimes the "test line 2" email came in before the "test line 1". As a brute force approach, I could schedule the dnsblstat to run some number of minutes before midnight, to make sure it completed before the log files were rotated "out from under it", but then I might miss a few discards, and I wanted to show each user every email that was discarded. A different approach would be to process the maillog.1.gz file after it is created, and to collect statistics for today and the last 6 days instead of today and the last 7 days. I sure this is a standard problem with a "correct" solution, so how do you guys handle it? Thanks, Cla. (sorry for the verbosity)