From owner-freebsd-hackers Tue May 9 18:55:22 1995 Return-Path: hackers-owner Received: (from majordom@localhost) by freefall.cdrom.com (8.6.10/8.6.6) id SAA03783 for hackers-outgoing; Tue, 9 May 1995 18:55:22 -0700 Received: from bunyip.cc.uq.oz.au (bunyip.cc.uq.oz.au [130.102.2.1]) by freefall.cdrom.com (8.6.10/8.6.6) with SMTP id SAA03776 for ; Tue, 9 May 1995 18:55:17 -0700 Received: from s1.elec.uq.oz.au by bunyip.cc.uq.oz.au with SMTP (PP); Wed, 10 May 1995 11:55:01 +1000 Received: by s1.elec.uq.oz.au (4.0/SMI-4.0) id AA08299; Wed, 10 May 95 12:50:12 EST From: clary@elec.uq.oz.au (Clary Harridge) Message-Id: <9505100250.AA08299@s1.elec.uq.oz.au> Subject: Compression and rotation of log files To: freebsd-hackers@FreeBSD.org Date: Wed, 10 May 95 12:50:11 EST X-Mailer: ELM [version 2.3 PL1] Sender: hackers-owner@FreeBSD.org Precedence: bulk How about using something like the following shell script for saving space when the log files get rotated in daily and weekly cron scripts? /etc/weekly ================================================================ #echo "Rotating messages:" /usr/local/etc/Rotate messages /var/log # if you want mode other than 600 chmod 644 messages kill -1 `cat /var/run/syslog.pid` #echo "Rotating cron log:" /usr/local/etc/Rotate log /var/cron #echo "" #echo "Rebuilding locate database:" ================================================================ #! /bin/sh # C.H. 2 Nov 92 # Rotate log files after compressing them # # Usage: Rotate file directory # DIR=/var/log case $# in 1) ;; 2) DIR=$2 ;; *) echo usage: ' Rotate file [directory]' exit ;; esac # cd $DIR # if [ -f $1 ] then /usr/bin/gzip -f $1 fi rm -f $1.7.gz for i in 6 5 4 3 2 1 0 do j=`expr "$i" + 1` if [ -f $1.$i.gz ] then mv $1.$i.gz $1.$j.gz fi done if [ -f $1.gz ] then mv $1.gz $1.0.gz fi case $DIR in *inetd) ;; *) cp /dev/null $1 chmod 600 $1 ;; esac cd / ================================================================ -- regards Dept. of Electrical Engineering, Clary Harridge University of Queensland, QLD, Australia, 4072 Phone: +61-7-365-3636 Fax: +61-7-365-4999 INTERNET: clary@elec.uq.oz.au