<br><br><div class="gmail_quote">On Wed, Apr 8, 2009 at 3:02 PM, Peter Corlett <span dir="ltr"><<a href="mailto:abuse@cabal.org.uk">abuse@cabal.org.uk</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
On Wed, Apr 08, 2009 at 02:49:15PM +0100, John Hearns wrote:<br>
[...]<br>
<div class="im">> That's more like it. But I can still make out access.log - so I can figure<br>
> out it does something with access logs. More compression! More confusion!<br>
<br>
</div>Nah, that's a terrible idea. The original, non-obfuscated version I slapped<br>
together in a few minutes is this one, which should be more obvious:<br>
<br>
#!/usr/bin/env perl<br>
use warnings;<br>
use strict;<br>
<br>
my($fh, $curpath);<br>
<br>
while(<>) {<br>
  my($day, $month, $year) = (m~\[(..)/(...)/(....):~);<br>
  die "Regex match failed" unless defined $1; # regex sanity check<br>
  my $path = "$year-$month-$day.access.log";<br>
<br>
  unless($fh && $curpath eq $path) {<br>
    $curpath = $path;<br>
    open $fh, '>', $path or die "Can't create $path: $!";<br>
  }<br>
  print $fh $_;<br>
<br>
  # uncomment if you want progress reports<br>
  #print STDERR "[$.] $curpath\r" unless $. % 1e4;<br>
}<br>
<br>
__END__<br>
<br>
(And this is a proper, solid, efficient script, unlike some of the crap that<br>
has been posted so far.)<br>
<br>
Change the $path assignment and maybe the date-extracting regex to taste. I<br>
ran it like so to test:<br>
<br>
zcat -f apache2/*access* | ./logsplit.pl<br>
<br>
... and it ripped through 80MB of test logs in three seconds. So 40GB will<br>
probably take of the order of an hour. (The main constraint is going to be<br>
disk performance.)<br>
<div><div></div><div class="h5"><br>
--<br>
Gllug mailing list  -  <a href="mailto:Gllug@gllug.org.uk">Gllug@gllug.org.uk</a><br>
<a href="http://lists.gllug.org.uk/mailman/listinfo/gllug" target="_blank">http://lists.gllug.org.uk/mailman/listinfo/gllug</a></div></div></blockquote><div><br>That looks great but I am using the timestamps in the actual logfile (which from what I can work out that script uses the date in the log file name but that maybe a error of judgment?<br>
<br>I have just ordered Perl for system administration also as I think Perl is another thing I should really learn.  <br><br>Thanks,<br>Will<br></div></div><br>