Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 24 Jun 2000 00:49:58 +0100
From:      Ben Smithurst <ben@scientia.demon.co.uk>
To:        FreeBSD-gnats-submit@freebsd.org
Subject:   bin/19483: option to compress accounting files in /var/account
Message-ID:  <E135dCw-000L50-00@magnesium.scientia.demon.co.uk>

next in thread | raw e-mail | index | archive | help

>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




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?E135dCw-000L50-00>