From owner-freebsd-isp Sat Jun 9 17: 3:39 2001 Delivered-To: freebsd-isp@freebsd.org Received: from liberty.bulinfo.net (liberty.bulinfo.net [212.72.195.7]) by hub.freebsd.org (Postfix) with SMTP id 0AF8437B401 for ; Sat, 9 Jun 2001 17:03:34 -0700 (PDT) (envelope-from krassi@bulinfo.net) Received: (qmail 82550 invoked from network); 6 Jun 2001 08:38:08 -0000 Received: from pythia.bulinfo.net (HELO bulinfo.net) (212.72.195.5) by liberty.bulinfo.net with SMTP; 6 Jun 2001 08:38:08 -0000 Message-ID: <3B1DEBED.B7C40AEA@bulinfo.net> Date: Wed, 06 Jun 2001 11:38:05 +0300 From: Krassimir Slavchev X-Mailer: Mozilla 4.77 [en] (X11; U; Linux 2.2.13 i686) X-Accept-Language: en MIME-Version: 1.0 To: Jan Knepper , FreeBSD-ISP Subject: Re: Log file rotation with Apache. References: <3B13D6DC.5040201@digitaldaemon.com> <3B1DEB36.A49DB40A@bulinfo.net> Content-Type: multipart/mixed; boundary="------------885661A622A17D5AAA1F8CE4" Sender: owner-freebsd-isp@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.org This is a multi-part message in MIME format. --------------885661A622A17D5AAA1F8CE4 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Ooops, forgot attachment:( Sorry! Krassimir Slavchev wrote: > Hello All, > > See attachment! > This perl script is not perfect, but will do all necessary. > -- Krassimir Slavchev Bulinfo Ltd. krassi@bulinfo.net (+359-2)963-3652 http://www.bulinfo.net (+359-2)963-3764 --------------885661A622A17D5AAA1F8CE4 Content-Type: application/x-perl; name="rotate2.pl" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="rotate2.pl" #!/usr/bin/perl ###_________________________________________(c) DieselOS ## Structure of rotate.conf file (for example) ## logfile count size_in_Kbytes #/var/log/access.log 3 1024 # use strict; # Change paths if differ! my $conf_file = "/etc/rotate.conf"; my $MV = "/bin/mv"; my $GZIP = "/usr/bin/gzip"; my ($logfile, $count, $size, $i, $n); open(FILE, "<$conf_file") || die "Can not open file: $conf_file!\n"; while() { next if /^#/; # Commented line ! s/^\s+//; s/\s+$//; next unless $_; ($logfile, $count, $size) = split(/\s+/, $_); if (-s $logfile > $size * 1024) # rotate if size exceed (in Kbytes!) { for ($i = $count-1; $i > 0; $i--) { $n = $i-1; if (-e "$logfile.$n.gz") { `$MV $logfile.$n.gz $logfile.$i.gz`; } } `$GZIP -c $logfile > $logfile.0.gz;>$logfile`; } } close FILE; --------------885661A622A17D5AAA1F8CE4-- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-isp" in the body of the message