On my Fedora 33 system, the systemd journal is persistently logged. Over time, the size of the log accumulate quite a lot.
# du -shx journal/
4.2G journal/
I already cleaned up the log twice in the past, but I already forgot how to do it. To fix my short-term memory, I’m going to document how I do this by following this blog post Clear systemd journal.
The command for cleaning up old logs is journalctl
with the option --vaccume-time=OLDER_THAN_TIME
. To read more about this, we can check the journactl
manual page. (man journalctl
and search for vacuume
key word.)
I’m going to remove any log file that is older than 7 days.
# journalctl --vacuum-time=7d
...
Vacuuming done, freed 3.9G of archived journals from /var/log/journal/8d0434dbcc454db49d61aa54595268aa.
Vacuuming done, freed 0B of archived journals from /var/log/journal.
Vacuuming done, freed 0B of archived journals from /run/log/journal.
Let’s verify the disk usage in /var/log/journal
directory again.
# du -shx /var/log/journal
137M /var/log/journal
This is awesome!
Reference: