logrotate(8) and copytruncate as default

Jan Kaluza jkaluza at redhat.com
Fri Jun 28 05:31:06 UTC 2013


----- Original Message -----
>    Hello Lennart, Colin,
> 
> ----- Original Message -----
> > From: Lennart Poettering <mzerqung at 0pointer.de>
> > Subject: Re: logrotate(8) and copytruncate as default
> > 
> > The systemd-journald takes care of all of: receiving messages, writing
> > them to storage, and rotating the storage.
> >
> > We do synchronous rotation before each write. i.e. the moment we append
> > to a file we check if the write would cause the disk usage to be out of
> > limits, and then do the rotation right away.
> 
>    I see.  While doing this rotation, I guess systemd uses flock(2) or
>    similar
> mechanism to pause writing to a log file, move/rename or copy-truncate that
> file and continue writes again?

I think difference between systemd and logrotate in this case is that
logrotate is not owner of the logs it rotates. It has no control of writing
to them. I haven't checked that journald code, but journald definitely controls
the log and is (correct me if I'm wrong) the only application writing to it.
Therefore it's not problem for journald to just write some line to log, check
that the log is too big and rotate it. It doesn't have to do any locking
to stop writing, it just does not write any data there during rotation.

You can't use this strategy with logrotate, but there are tools using this
way too (for example "rotatelogs" from httpd-tools package).

> > You can configure how much disk space journald should take up at max,
> > and how much you want to remain free.
> > 
> > You can also configure a time limit, to enforce that everything older
> > than a certain time is always cleaned up (though this is really
> > something for weird data retention policy setups, normal users should
> > not need it, disk space is a much more useful limiter).
> 
>    Ah, cool! That's interesting. Thanks so much for this insight.
> 
> Thank you!
> 
> ---
> Regards
>    -Prasad
> http://feedmug.com
> --
> devel mailing list
> devel at lists.fedoraproject.org
> https://admin.fedoraproject.org/mailman/listinfo/devel

Jan Kaluza


More information about the devel mailing list