Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

How to read the log rotated file

by kar_thik82 (Novice)
on Mar 07, 2013 at 07:03 UTC ( [id://1022154]=perlquestion: print w/replies, xml ) Need Help??

kar_thik82 has asked for the wisdom of the Perl Monks concerning the following question:

Hi Monks

Just want to what is the best way to read the rotated file i am developing a log monitoring solution for Solaris Syslog where i am reading the /var/adm/messages file. At the time of rotation the Archived file messages.1 will have some latest errors how to handle this situation. The current logic which i am trying to concatenate the two files messages and messages.1 and sending the errors. Is there any best possible way to handle this log rotation other than concatenating the files. which is a very slow process

Replies are listed 'Best First'.
Re: How to read the log rotated file
by rnewsham (Curate) on Mar 07, 2013 at 09:57 UTC
    You could use File::ReadBackwards to read messages.1 until you reach the point where your previous scan ended. That way you only need to read the lines you need rather than the whole file.

      Thanks for your help will the File::ReadBackwards takes the cursor position since i am using tell function to store the current position of the file

Re: How to read the log rotated file
by tmharish (Friar) on Mar 07, 2013 at 07:34 UTC

    Please note that the section "Perl Monks Discussion" is " only for discussing issues pertaining to the PerlMonks web site."

    Please use the section Seekers of Perl Wisdom for "question on how to do something in Perl, or you need a Perl solution to an actual real-life problem, or you're unsure why something you've tried just isn't working..."

    I have moved this to SoPW.

    Second post today!!

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://1022154]
Approved by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (2)
As of 2025-03-21 08:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    When you first encountered Perl, which feature amazed you the most?










    Results (63 votes). Check out past polls.