Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
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 musing on the Monastery: (12)
As of 2015-07-30 12:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (271 votes), past polls