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
In reply to •Re: File tracking
by merlyn
in thread File tracking
by r
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |