Systems / Field notes
Managing Linux system logs
Logs are an operational resource. They help explain failures, audit changes and reconstruct incidents, but unlimited retention can turn an ordinary application fault into a storage outage.
Find the main consumers
Inspect filesystem capacity, the journal’s disk usage and large log directories. A single verbose service may dominate storage even when the rest of the system is quiet. Distinguish the systemd journal from conventional log files, application-specific logs and compressed archives.
df -h /
journalctl --disk-usage
sudo du -h -d 1 /var/log | sort -h
journalctl -p warning -b --no-pager -n 50Set a realistic journal budget
On a small server, choose a journal limit and free-space reserve based on disk capacity, event rate and incident-response requirements. The following is an illustrative journald configuration, not a universal recommendation. Review existing settings and overrides first.
[Journal]
SystemMaxUse=100M
SystemKeepFree=1G
MaxRetentionSec=30dayJournal limits are not a guarantee that every event survives for the specified period. High message rates may shorten retention, and active files can affect reported usage. Rotation and vacuuming remove eligible archived journals; preserve evidence before performing cleanup.
Traditional logs need their own policy
Logrotate handles conventional files using rules for size, time, retention and compression. A maximum size is checked when logrotate runs, not continuously. Review the timer frequency if a noisy service can fill the disk between runs. Use debug mode to inspect the proposed actions before changing a policy.
sudo logrotate -d /etc/logrotate.conf
systemctl list-timers logrotate.timerReduce unnecessary verbosity
Use debug logging during a bounded investigation, then return to an appropriate production level. Retain relevant security and error events. Monitor disk space separately so logging failures can be detected even when the log itself stops growing.