From owner-freebsd-bugs Fri Jun 23 20:50: 7 2000 Delivered-To: freebsd-bugs@freebsd.org Received: from freefall.freebsd.org (freefall.FreeBSD.ORG [204.216.27.21]) by hub.freebsd.org (Postfix) with ESMTP id 7E13137B507 for ; Fri, 23 Jun 2000 20:50:01 -0700 (PDT) (envelope-from gnats@FreeBSD.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.9.3/8.9.2) id UAA27871; Fri, 23 Jun 2000 20:50:01 -0700 (PDT) (envelope-from gnats@FreeBSD.org) Received: from scientia.demon.co.uk (scientia.demon.co.uk [212.228.14.13]) by hub.freebsd.org (Postfix) with ESMTP id 6E31837B747 for ; Fri, 23 Jun 2000 20:40:40 -0700 (PDT) (envelope-from ben@scientia.demon.co.uk) Received: from magnesium.scientia.demon.co.uk ([192.168.91.34] ident=exim) by scientia.demon.co.uk with esmtp (Exim 3.15 #1) id 135dCx-000CRC-00 for FreeBSD-gnats-submit@freebsd.org; Sat, 24 Jun 2000 00:49:59 +0100 Received: (from ben) by magnesium.scientia.demon.co.uk (Exim 3.15 #1) id 135dCw-000L50-00 for FreeBSD-gnats-submit@freebsd.org; Sat, 24 Jun 2000 00:49:58 +0100 Message-Id: Date: Sat, 24 Jun 2000 00:49:58 +0100 From: Ben Smithurst Reply-To: ben@scientia.demon.co.uk To: FreeBSD-gnats-submit@freebsd.org X-Send-Pr-Version: 3.2 Subject: bin/19483: option to compress accounting files in /var/account Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org >Number: 19483 >Category: bin >Synopsis: option to compress accounting files in /var/account >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: change-request >Submitter-Id: current-users >Arrival-Date: Fri Jun 23 20:50:00 PDT 2000 >Closed-Date: >Last-Modified: >Originator: Ben Smithurst >Release: FreeBSD 3.4-STABLE i386 >Organization: >Environment: >Description: The accounting files under /var/account can grow quite large, so it would be nice to have an option to compress them as part of the daily run. I've been doing this for a while, but didn't send-pr it because I thought people might object. Now it's all configurable, I can't see a problem, so the attached patch will do this. >How-To-Repeat: >Fix: Index: defaults/periodic.conf =================================================================== RCS file: /usr/cvs/src/etc/defaults/periodic.conf,v retrieving revision 1.1 diff -u -r1.1 periodic.conf --- periodic.conf 2000/06/23 01:18:21 1.1 +++ periodic.conf 2000/06/23 23:42:19 @@ -68,6 +68,7 @@ # 310.accounting daily_accounting_enable="YES" # Rotate acct files +daily_accounting_compress="NO" # Gzip rotated files # 320.distfile daily_distfile_enable="YES" # Run rdist daily Index: periodic/daily/310.accounting =================================================================== RCS file: /usr/cvs/src/etc/periodic/daily/310.accounting,v retrieving revision 1.4 diff -u -r1.4 310.accounting --- 310.accounting 2000/06/23 01:18:23 1.4 +++ 310.accounting 2000/06/23 23:25:56 @@ -19,10 +19,28 @@ echo "Rotating accounting logs and gathering statistics:" cd /var/account - [ -f acct.2 ] && mv -f acct.2 acct.3 - [ -f acct.1 ] && mv -f acct.1 acct.2 - [ -f acct.0 ] && mv -f acct.0 acct.1 + + # Delete any old files left around if the user changes from + # non-compressed to compressed or vice-versa. + find . -name 'acct.*' -mtime +5 -delete + + # Does the user want the files compressed? + case "$daily_accounting_compress" in + [Yy][Ee][Ss]) + ext=".gz" ;; + *) + ext="" ;; + esac + + [ -f acct.2$ext ] && mv -f acct.2$ext acct.3$ext + [ -f acct.1$ext ] && mv -f acct.1$ext acct.2$ext + [ -f acct.0$ext ] && mv -f acct.0$ext acct.1$ext cp -pf acct acct.0 sa -s >/dev/null + + case "$daily_accounting_compress" in + [Yy][Ee][Ss]) + gzip -f acct.0 ;; + esac fi;; esac >Release-Note: >Audit-Trail: >Unformatted: To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message