Date: Wed, 06 Jun 2001 11:38:05 +0300 From: Krassimir Slavchev <krassi@bulinfo.net> To: Jan Knepper <jan@digitaldaemon.com>, FreeBSD-ISP <freebsd-isp@freebsd.org> Subject: Re: Log file rotation with Apache. Message-ID: <3B1DEBED.B7C40AEA@bulinfo.net> References: <3B13D6DC.5040201@digitaldaemon.com> <3B1DEB36.A49DB40A@bulinfo.net>
next in thread | previous in thread | raw e-mail | index | archive | help
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(<FILE>) { 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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?3B1DEBED.B7C40AEA>
