logrotate
Cheat sheet · https://pcornel.dk/topic.php?topic=2823
Answer
logrotate rotates, compresses and deletes old log files on a schedule (daily via a timer or cron), using /etc/logrotate.conf and per-application files in /etc/logrotate.d/.
Remember
After rotating, the program must reopen its log (postrotate reload, or copytruncate). Test with logrotate -d (dry run) and force with logrotate -f. Files not matching any rule are never rotated.
First checks
logrotate -d <conf>— dry runjournalctl -b -p warning— warnings and errors since bootjournalctl -u <unit> -f— follow one unit's logls -lh /var/log— log files and sizeslogger -p user.info test— send a test message
Verify in this order
schedule triggers → file matches a rule → renamed/compressed → program reopens its log → old files deleted
Where it usually breaks
First mismatch in persistent unit/config/generator → dependency/order graph → systemd state → process/cgroup → socket/resource dependency → journal → consumer check; preserve identity/native diagnostic/pre-state before mutation.
Read-only verification commands unless stated otherwise. Confirm syntax for your platform and release. Full reference: https://pcornel.dk/topic.php?topic=2823