From owner-freebsd-questions Wed May 1 07:49:01 1996 Return-Path: owner-questions Received: (from root@localhost) by freefall.freebsd.org (8.7.3/8.7.3) id HAA13028 for questions-outgoing; Wed, 1 May 1996 07:49:01 -0700 (PDT) Received: from fledge.watson.org (root@FLEDGE.RES.CMU.EDU [128.2.95.74]) by freefall.freebsd.org (8.7.3/8.7.3) with SMTP id HAA13018 for ; Wed, 1 May 1996 07:48:52 -0700 (PDT) Received: (from root@localhost) by fledge.watson.org (8.6.12/8.6.10) id KAA22534; Wed, 1 May 1996 10:48:36 -0400 Date: Wed, 1 May 1996 10:48:35 -0400 (EDT) From: System Administrator To: questions@freebsd.org Subject: /etc/monthly, /etc/daily -- log rotation Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-questions@freebsd.org X-Loop: FreeBSD.org Precedence: bulk While perusing a BSDI system I used to administrate, I found the following code in /etc/monthly and /etc/daily that seemed to make a lot more sense that some of the stuff I saw in our equivilant files: rotate() { file="$1"; shift rm -f "$file.$1" "$file.$1.gz" for i in "$@"; do [ "$i" = "0" ] && j="" || j=".`expr $i - 1`" [ -f "$file$j.gz" ] && mv -f "$file$j.gz" "$file.$i.gz" [ -f "$file$j" ] && mv -f "$file$j" "$file.$i" [ "$i" = "0" -a -x $file.scan ] && $file.scan "$file.$i" [ -f "$file.$i" ] && [ "X$ziplog" = "XYES" ] && /usr/bin/gzip "$file.$i" done cp /dev/null "$file"; chmod 644 "$file" } Calling is done as follows: rotate /var/log/maillog 6 5 4 3 2 1 0 rotate /var/log/wtmp 6 5 4 3 2 1 0 rotate /var/log/popper 4 3 2 1 0 Etc. It seems a lot more modular and configurable, etc. It certainly makes the script files seem more readable -- maybe we should consider adopting a similar rotate call? Robert Watson robert@fledge.watson.org / http://www.watson.org