in reply to File tracking
That last step is critical. There must be some way to let the writer know that the file they have open is now a new file.#!/usr/bin/perl -w use strict; $|++; ### Processed automatically at 10:29:34 21-Jun-2002 from + ### ### sbin/log-roller.tmpl edited at 07:58:15 17-May-2002 + ### my $PIDFILE = "/web/stonehenge/var/run/httpd.pid"; my @LOGS = glob("/web/stonehenge/var/log/*_log"); ## first, compress any old log files if (my @OLDLOGS = grep -M > 7, glob("/web/stonehenge/var/log/*[0-9]")) + { system 'gzip', '-9', @OLDLOGS; } ## then, get the PID open PIDFILE, $PIDFILE or die "Cannot open $PIDFILE: $!"; chomp(my $pid = <PIDFILE>); close PIDFILE; $pid =~ /\d+/ or die "$pid doesn't look like a pid from $PIDFILE"; ## now roll the logs { local *ARGV; local $^I = "." . time; @ARGV = @LOGS; close ARGV while <>; # quick rename while emptying } ## finally, let Apache know we've messed around kill 'USR1', $pid or warn "Cannot send USR1 to $pid: $!";
-- Randal L. Schwartz, Perl hacker
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: •Re: File tracking
by r (Initiate) on Jul 06, 2002 at 17:35 UTC | |
by ehdonhon (Curate) on Jul 06, 2002 at 18:57 UTC | |
by r (Initiate) on Jul 06, 2002 at 19:35 UTC | |
|
Re: •Re: File tracking
by Juerd (Abbot) on Jul 06, 2002 at 18:01 UTC |