* Andrew Bower <and...@bower.uk> [250203 23:39]:
> Control: tags -1 patch
> 
> On Sat, Feb 01, 2025 at 09:24:31PM +0000, Andrew Bower wrote:
> > wtmpdb will rotate logs but nothing will prune them (like logrotate would 
> > for
> > other types of log - unfortunately it doesn't fit in well with the wtmpdb 
> > way).
> 
> I have come up with a solution whereby a 'prune' systemd unit is chained
> from the 'rotate' service. This calls into a script to prune logs beyond
> a configured limit. One can disable the prun unit or edit it to adjust
> the parameters.

> Any feedback much appreciated!
> 
> https://salsa.debian.org/abower/wtmpdb/-/commit/512fa747f9943e1b8b4e7c169dabc1c67c004313
> (branch 'log-pruning')

ISTM this is a lot of new, potentially fragile sh code, possibly
with undefined semantics. Indeed shellcheck has a lot of things to
say, including:

| In prune-logs line 9:
| set -o pipefail
|        ^------^
| SC3040 (warning): In POSIX sh, set option pipefail is undefined.

I'm not an expert in sh scripting, but I'd try to make it shellcheck
clean. Generally I think whatever Debian ends up shipping should
also go upstream.

> One nicety of the old wtmp logrotate config is that it wouldn't even
> rotate until the log hit 1MB.
> 
> What do we think of that idea? It seems logical - no point in rotating
> tiny files!

It's a trade off to what should be kept. If you have strict
requirements on how many days can be kept, then also small files
must be treated.

Maybe a find call with -mtime <something> would be enough.

Chris

Reply via email to