I think you have me backwards.  I'm not monitoring the log file, I'm writing to it 
(append mode).  Within perl, I need
to know when an outside process has renamed the log file so I can reinitialize the log 
output to a new file (the correct
file name).

----- Original Message ----- 
From: "Robby Russell" <[EMAIL PROTECTED]>
To: "TeamSolCO" <[EMAIL PROTECTED]>
Sent: Thursday, January 29, 2004 4:54 PM
Subject: Re: logrotate and perl file handles. How do I know when to reopen my log file?


: TeamSolCO typed this on 01/29/2004 01:16 PM:
: >     I have written a long running perl application to help me with some trivial 
administrative functions.  Due to
the
: > volume of logging generated by this application, I am managing its output with 
logrotate.  The problem I face is
that
: > perl is "following" the log files that logrotate swaps out.  While this is 
probably intelligent on perl's part (to
: > follow the file descriptor rather than the file name), it is presenting a major 
problem for me.  When "logfile"
becomes
: > "logfile.1" (etc), my application follows that move and "continues" logging to the 
new "logfile.1" instead of losing
: > that file handle -- a condition which I check for so that I can reopen the log 
file using the proper file name,
: > "logfile".
: >     Ultimately, perl will only lose the file handle when logrotate finally deletes 
the "last file" in the log
rotation
: > scheme.  Unfortunately, I will have lost a week's worth of logs because all that 
data will have been in the single
file.
: > Additionally, I'll have several empty log file copies named .1, .2, .3, etc.  How 
can I set perl to NOT follow the
file
: > when it is renamed by logrotate, such that a condition will be created where I 
will be able to initialize the
: > replacement file?
: >
: > Thanks!!
: >
: > - William Kimball
: >   "Programming is an art-form that fights back!"
: >
:
: Do you want to only monitor the original logfile or logfile.1 as well?
:
: You can use the perl module, File::Tail for monitoring logfile, even
: through logrotate.
:
: -Robby
:
:
: -- 
: #-------------------------------------------------------
: # Robby Russell,  |  Sr. Administrator / Lead Programmer
: # Command Prompt, Inc.   |  http://www.commandprompt.com
: # [EMAIL PROTECTED] | Telephone: (503) 667.4564
: #-------------------------------------------------------
:
:



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to