Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
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.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://950659]
help
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (3)
As of 2016-12-11 01:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    On a regular basis, I'm most likely to spy upon:













    Results (168 votes). Check out past polls.