Re: logrotate and perl file handles. How do I know when to reopen my log file?
From: Teamsolco (teamsolco_at_teamdelsol.com)
Date: 01/30/04
- Next message: Jenda Krynicky: "Re: LOST - Win32::Process"
- Previous message: Larry Snider: "Re: [meta] Please delete boilerplate! (was Re: Covert Date to week number)"
- Maybe in reply to: Teamsolco: "logrotate and perl file handles. How do I know when to reopen my log file?"
- Next in thread: John McKown: "Re: logrotate and perl file handles. How do I know when to reopen my log file?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
To: "Robby Russell" <rrussell@commandprompt.com> Date: Thu, 29 Jan 2004 17:02:11 -0700
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" <rrussell@commandprompt.com>
To: "TeamSolCO" <teamsolco@teamdelsol.com>
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
: # rrussell@commandprompt.com | Telephone: (503) 667.4564
: #-------------------------------------------------------
:
:
- Next message: Jenda Krynicky: "Re: LOST - Win32::Process"
- Previous message: Larry Snider: "Re: [meta] Please delete boilerplate! (was Re: Covert Date to week number)"
- Maybe in reply to: Teamsolco: "logrotate and perl file handles. How do I know when to reopen my log file?"
- Next in thread: John McKown: "Re: logrotate and perl file handles. How do I know when to reopen my log file?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|