Subject: Re: Log rotation
To: Peter Seebach <seebs@plethora.net>
From: Luke Mewburn <lukem@NetBSD.org>
List: current-users
Date: 02/22/2005 11:39:10
--o605RBccvup4jNEP
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Fri, Feb 18, 2005 at 04:24:43PM -0600, Peter Seebach wrote:
  | Is there anything other than newsyslog.conf which offers reasonably
  | convenient log rotation? BSD/OS had a program called "rotate" which
  | could rotate a file, optionally compressing, on a regular basis.

pkgsrc/sysutils/logrot should do what you want; rotate, send signals
or run arbitrary commands after rotate, compress/filter, ...=20
It attempts to do the "rotate" as atomically as possible.

(This is a shameless plug: I wrote it years ago because I was unhappy
with newsyslog's functionality at the time and I needed something to
run on Solaris as well.)

It doesn't have a configuration file; just add separate crontab entries
for each group of configs you wish to rotate.

For example, I have the following crontab entries (lines wrapped for
easier reading):

	0 6 * * 3 cd /var/log ; logrot -d old -c auth authpriv cron daemon \
	    ftp kern local0 local1 local2 local3 local4 local5 local6 local7 \
	    lpr mail news syslog user uucp

	20 6 * * 3 cd /var/squid ; logrot -d old -s USR1 -w 60 \
	    -p /var/run/squid.pid -c -B 'case "\%f" in access*) cat "\%f" | \
	    calamaris -a | mail -s "proxywww cache report" root;; esac' \
	    cache access

	10 6 * * 3 cd /var/log ; logrot -d old -c \
	    -N "/etc/rc.d/upslog restart" ups

	15 6 * * 3 cd /var/log ; logrot -d old -w 60 \
	    -N '/etc/rc.d/apache reload' -c \
	    apache.access apache.error apache.ssl apache.ssl_engine

These rotate various files in various directories, storing the compressed
rotated files in ./old/logname.YYMMDD.gz, notifying various services
as appropriate (HUP syslog and squid, reload apache, restart ups-nut, ...).

YMMV.

Cheers,
Luke.

--o605RBccvup4jNEP
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.6 (NetBSD)

iD8DBQFCGn8upBhtmn8zJHIRAmpmAJ9WcyfrUrVJpnFFrEYjyTdqc43fXQCggf2B
E/4s7//whXuC5G5+akkW/K8=
=FXPl
-----END PGP SIGNATURE-----

--o605RBccvup4jNEP--