[ale] Cooperating with logrotate

Scott McBrien smcbrien at gmail.com
Fri Nov 6 13:41:10 EST 2009


Check out the logrotate for httpd in /etc/logrotate.d, it sounds like  
what you need is a post rotate script like what apache uses.

-Scott

On Nov 6, 2009, at 12:32 PM, JK <jknapka at kneuro.net> wrote:

> Hi folks,
>
> I have a very long-running server process that generates a lot of
> log data over time. One instance is currently appending to a 9GB
> logfile.  The server process opens the log file in "w" mode and
> holds it open forever.
>
> Is there any way logrotate can work nicely with this?  What I see
> happening is that if I use the "copytruncate" option to logrotate,
> it copies the file and truncates it (so the on-disk size is 0
> until the server appends more log data).  However, the *apparent*
> size remains 9GB, presumably because the server continues to append
> at the current file offset, leaving a 9GB hole at the front. Next
> time logrotate runs (and the file is apparently 9.5 GB), it copies
> the whole 9.5GB -- but logrotate actually writes a new file with
> all those nulls in it, rather than writing a file with a 9GB hole
> at the front.  This is not very helpful! So I'd like to know if
> there's a way I can tell logrotate to only copy the actual data
> in the file.
>
> I think the correct answer is that the server process should do...
> something... to ensure that its logfile can be handled in a reasonable
> way by logrotate.  But what is that "something"?  (The logrotate
> man page is of no help.)
>
> Thanks,
>
> -- JK
> _______________________________________________
> Ale mailing list
> Ale at ale.org
> http://mail.ale.org/mailman/listinfo/ale
> See JOBS, ANNOUNCE and SCHOOLS lists at
> http://mail.ale.org/mailman/listinfo


More information about the Ale mailing list