Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

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

Comment on How to read the log rotated 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!!

Re: How to read the log rotated file
by rnewsham (Hermit) 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

Log In?
Username:
Password:

What's my password?
Create A New User
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? | Other CB clients
Other Users?
Others studying the Monastery: (7)
As of 2014-09-01 21:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite cookbook is:










    Results (17 votes), past polls