Splitting log files

You’ve been remiss when it comes to rotating your log files. Now you want to do some log analysis on your logfiles. What to do.

  perl -MIO::All -MDateTime::Format::Strptime -ne '    my $p = DateTime::Format::Strptime->new(pattern=>"%b-%Y") || die $!;    my $fname=substr($p->parse_datetime(                            join("-",                                 (split(m{[:/]}, [split(/\s+/)]->[3]))[1,2]))                         ->ymd,                     0, 7);    io("access-$fname.log")<<$_' access.log  

Put all that one one line and you’re good to go.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.