[Dnsmasq-discuss] log rotation again...

Simon Kelley simon at thekelleys.org.uk
Sat May 5 17:31:48 BST 2007

Carlos Carvalho wrote:
> Simon Kelley (simon at thekelleys.org.uk) wrote on 1 May 2007 20:23:
>  >> Exactly, that's what I had in mind. The savelog script in Debian can
>  >> also do it.
>  >
>  >Another new thing I learned today. I don't like savelog's compression 
>  >scheme though. Ignoring the older files, is seems to to
>  >
>  >mv log.0 log.1
>  >compress log.1
>  >touch log.0
>  >
>  >and then the signal can be sent. Since the old file (renamed to log.1) 
>  >can still be written 'till the signal is sent, and some time afterwards,
>  >then the compressedfile might be written to and corrupted. I think the 
>  >scheme where log.0 and log.1 are uncompressed and only log.2, log3 etc 
>  >are compressed is much safer.
> Agreed. However the risky behavior is not savelog's. With
> savelog one has
>    file   file.0   file.1.{gz,bz2} etc.
> "file" is the newly created, file.0 is the previous version of "file"
> just renamed that may still be in use. For this reason savelog
> compresses only starting with file.1. I agree the man page is
> misleading but the code makes this clear, and there's also a comment
> in the beginning:
> # The savelog command saves and optionally compresses old copies of files.
> # Older version of 'file' are named:
> #
> #               'file'.<number><compress_suffix>
> #
> # where <number> is the version number, 0 being the newest.  By default,
> # version numbers > 0 are compressed (unless -l prevents it). The
> # version number 0 is never compressed on the off chance that a process
> # still has 'file' opened for I/O.

I understand: I was mislead by the manpage.

> On the other hand, the default with logrotate is not the safe one. If
> one specifies compress without delaycompress the mess you described
> happens. One must also be careful with postrotate scripts for a group,
> because these are only executed after all logs have been rotated, and
> compression starts right after each rotation. This means the group
> postrotate, which usually sends the HUP to the daemon(s), will only
> run after compression has started. If delaycompress is not used...
> oops...

That explains why the Debian logrotate config uses delaycompress.
>  >I'll get some code out this week sometime, unless I get too busy.
> Wonderful! :-) I'll test it as soon as you post it.

OK, it's there:




More information about the Dnsmasq-discuss mailing list