Date: Wed, 10 May 95 12:50:11 EST From: clary@elec.uq.oz.au (Clary Harridge) To: freebsd-hackers@FreeBSD.org Subject: Compression and rotation of log files Message-ID: <9505100250.AA08299@s1.elec.uq.oz.au>
next in thread | raw e-mail | index | archive | help
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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?9505100250.AA08299>