On Tue, 2006-02-21 at 11:38 -0800, Ranga Nathan wrote:

> I will have to re-start the script after every log rotation! I wish I 
> could do this programmatically. Perhaps another script to monitor the log 
> file and notice the sudden change in size or inode.

This is from the man page for tail:

--max-unchanged-stats=N
    with  --follow=name,  reopen  a FILE which has not changed size
    after N (default 5) iterations to see if it has  been  unlinked
    or renamed (this is the usual case of rotated log files)

So you could stat() the handle every so often (e.g. use a timeout on
your select() call) and store the size.  If the size doesn't change for
5 iterations, stat the original filename to see if the mtime is
different from that of the handle.

Maybe you could watch the mtime instead of the size in the first place?
It's not clear to me why less watches for unchanging size and not mtime.
Perhaps some daemons somehow affect the mtime on their logs without
actually appending any data?


 -- Jeremy

 
_______________________________________________
Boston-pm mailing list
[email protected]
http://mail.pm.org/mailman/listinfo/boston-pm

Reply via email to