Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
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

Replies are listed 'Best First'.
Re: How to read the log rotated file
by rnewsham (Chaplain) 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
Node Status?
node history
Node Type: perlquestion [id://1022154]
Approved by Corion
help
Chatterbox?
[Corion]: marto: Yeah, I can imagine that
[choroba]: create a ticket if the number of tickets reaches a limit
[choroba]: how deep meta could it go?
[marto]: this sounds like a sub section for Sane Dots
[Corion]: marto: You mean "Sane Dots Dramatic Reading of ITIL" ? ;)

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (9)
As of 2017-01-24 10:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you watch meteor showers?




    Results (203 votes). Check out past polls.