PROPHET/OS
NAME
logrotate: rotates files under /log that grew past the threshold,
SYNOPSIS
logrotate [bytes|look [path]]
DESCRIPTION
Rotates files under /log that grew past the threshold,
keeping a few generations (.1 .2 .3). Run it from cronv.
A log that is never rotated fills the root, and a root that is full stops more than the logging.
A number as the argument sets the threshold for this run, above the config and the default.
logrotate look [path] counts the files and the ones past the threshold and rotates nothing, so the walk can be driven on a directory of the machine without touching a log.
The walk, and what it costs
One entry at a time and two walks per directory. Only one of the two changes the directory it walks: a step into a child leaves this one alone, so the enumeration by index holds over it; a rotation renames in this directory, so the second walk starts again after every rotation and ends because a rotated name carries a digit and is no candidate any more.
A level of the recursion holds one entry (80 bytes) and one path (256 bytes), so the seven levels cost about 2,5 KiB of the 64 KiB a program has. Until 2026-10-14 a level held 64 entries at once, 5120 bytes each and 35 KiB over the seven, and a directory with more than 64 entries was skipped in silence (R12-ROTATE-01).
EXAMPLE
$ logrotate --help logrotate [bytes|look [path]] rotates files under /log that grew past the threshold, keeping a few generations (.1 .2 .3). Run it from cronv. look counts what is due and rotates nothing