From owner-freebsd-questions Wed Dec 4 21:55: 4 2002 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 2316337B401 for ; Wed, 4 Dec 2002 21:55:03 -0800 (PST) Received: from mail.gascom.ru (mail.gascom.ru [217.17.160.2]) by mx1.FreeBSD.org (Postfix) with SMTP id BCED643EA9 for ; Wed, 4 Dec 2002 21:55:01 -0800 (PST) (envelope-from asa@gascom.ru) Received: (qmail 47813 invoked from network); 5 Dec 2002 05:52:03 -0000 Received: from asa.gascom.net.ru (192.168.100.29) by mail.gascom.ru with SMTP; 5 Dec 2002 05:52:03 -0000 Subject: Re: run command on logfile before it's rotated From: Akifyev Sergey To: nkinkade@dsl-only.net Cc: freebsd-questions@FreeBSD.ORG In-Reply-To: <20021204220240.GY467@sub21-156.member.dsl-only.net> References: <93B9E916-07D2-11D7-B076-0003936CEB72@garbage.dk> <20021204220240.GY467@sub21-156.member.dsl-only.net> Content-Type: text/plain Content-Transfer-Encoding: 7bit X-Mailer: Ximian Evolution 1.0.8 Date: 05 Dec 2002 08:54:49 +0300 Message-Id: <1039067690.298.18.camel@asa.gascom.net.ru> Mime-Version: 1.0 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 Thu, 2002-12-05 at 01:02, Nathan Kinkade wrote: > On Wed, Dec 04, 2002 at 10:51:43PM +0100, Thomas von Hassel wrote: > > I've got my system set up to rotate the maillog every day at midnight. > > What do i do if i want to run a command on the logfile just before it's > > rotated ? > > > > /thomas > > -- > > Thomas von Hassel > > DarX @ irc > > darxmac @ AIM/iChat > > Powered by inkwell...! > > How about just setting a cron job to run some reasonable period prior > to newsyslog being run? It's incorrect way to do things, because some entries could be added to syslog _after_ the command is run, but _before_ newsyslog. Instead you should call some script via cron with crontab entry like this: # rotate log files every hour, if necessary 0 * * * * root /usr/bin/lock_script.sh And the script must contain something like: #!/bin/sh for $STR in `cat /etc/newsyslog.conf |grep -v '^[:space:]*#.*$'|cut -f1`; do lockf "${STR}" newsyslog.sh "${STR}" done The newsyslog.sh should contain: #!/bin/sh your_command "${1}" newsyslog "${1}" > Nathan > > To Unsubscribe: send mail to majordomo@FreeBSD.org > with "unsubscribe freebsd-questions" in the body of the message > Regards, Sergey To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message