Syntactic Confectionery Delight | |
PerlMonks |
Re: Tailing rolling logsby coec (Chaplain) |
on Jan 30, 2004 at 10:16 UTC ( [id://325192]=note: print w/replies, xml ) | Need Help?? |
Hmm, how does 'it stop working'? Depending entirely on how the log rotation occurs, after the rotation you could be looking at the original file, it just has a .1 extension now. RedHat's logrotate, for example and depending on the options supplied, may move/create. That is, it will move the existing file to a new location (and name) and create a new file of the original name. Now, your running script (which I've called logr.pl for ease of reference) doesn't refer to the log file by name but by inode. A good way to test this (under Linux) is to start your script: logr.pl -f messages and get the process ID of logr.pl. 'ls -l /proc/<PID>/fd' and look at the file handles that are in use by your process. Now manually rotate the file and repeat the 'ls' above. In my tests, the logr.pl still had the original file open. Under other Unixes, 'lsof' or 'fuser' may provide similar info. As to a fix, you could include signal handling in logr.pl to re-read the file (or simply restart) on receipt of SIGHUP, for example. I hope that answers the question (correctly)
In Section
Seekers of Perl Wisdom
|
|