Archiving a log file

Frank Leonhardt frank2 at fjl.co.uk
Sun Aug 4 23:28:36 UTC 2013


On 04/08/2013 14:38, Terje Elde wrote:
> On 4. aug. 2013, at 12:54, Frank Leonhardt <frank2 at fjl.co.uk> wrote:
>> The program writing the log is actually called flubnutz and it doesn't play nice with newsyslog, reopen handles on a signal or anything else
> Then you're out of luck for normal rotation. No matter if you rename the file, or even delete it, it'll keep writing to the same file (the moved file, not the same filename).
>
> I suppose your options are to either restart it to have it reopen the file, or if that's not desirable for whatever reason, look see if it'll play nice if you put a named pipe where the logfile is supposed to be. Then you can handle data as you'd like from the pipe.
>
> Terje
>
Thanks. The consensus seems to be that there is no way to do this other 
than "start from a different place". It'd be difficult for the kernel to 
trim a file from the start unless it was on a block boundary, so it's 
not implemented and explains the numerous work arounds for dealing with 
logs (fifo to log manager, signalling an application to reopen logs 
because file has changed and so on).

So I will carry on using my original bodge, happy in the knowledge that 
it may not be perfect, but there's no better method known to exist 
unless I want to implement a better truncate() in the kernel.

Regards, Frank.




More information about the freebsd-questions mailing list