Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?

How to read the log rotated file

by kar_thik82 (Novice)
on Mar 07, 2013 at 07:03 UTC ( #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 (Deacon) 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?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1022154]
Approved by Corion
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (12)
As of 2018-06-22 14:56 GMT
Find Nodes?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?

    Results (124 votes). Check out past polls.