Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: How to read from rotated log file?

by JavaFan (Canon)
on Jan 29, 2012 at 21:16 UTC ( #950659=note: print w/ replies, xml ) Need Help??


in reply to How to read from rotated log file?

I assume your system numbers log files, and that compressed log files end in .gz.

Let's assume your base file is called "my-app". Then it's time to use magic open! Untested:

my @files = </var/log/my-app*>; /\.gz/ and $_ = "zcat $_ |" for @files; local @ARGV = @files; while (<>) { ... do something with record ... }
This will read uncompressed files in the usual way, and read from a pipe (with zcat on the other end) for compressed files.


Comment on Re: How to read from rotated log file?
Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://950659]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (15)
As of 2014-07-25 16:39 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (174 votes), past polls