[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Re[2]: [cobalt-users] big trouble with log rotating



> Do you still have your script?

Sure. But it won't do you any good. You need to make one which searches for
your own domain names among the log lines.

Here's how the model goes, though:

#!/usr/bin/perl

$log = "/usr/var/log/access";
open(SCARE, ">>/home/sites/site1/logs/web.log") || die "cannot open 1";
open(CW,">>/home/sites/site9/logs/web.log") || die "cannot open 9";
<many other file handles omitted here for brevity>
open(OTHER,">>/root/lostlogs.dat") || die "cannot open lostlogs";

$i=0;

open(IN,"$log") || die "cannot read access";
while($_ = <IN>) {
  $line = $_;
  if($line =~ /^www\.seniorcare/) {
    print SCARE "$line";
  } elsif($line =~ /^crosswalk/) {
    print CW "$line";
<lots of elsifs omitted here for brevity>
  } else {
    print OTHER "$line";
  }
  $i++;
}
close(IN);
close(SCARE);
<ditto>
close(OTHER);

print "\n\nDONE\n$i lines\n";


Aloha