Thursday, April 2, 2020

Clear systemd journal

examples are taken here

Systemd stores its logs in /var/log/journal.
$ du -hs /var/log/journal/
4.1G    /var/log/journal/
Check the oldest logs date:
$ ls -lath /var/log/journal/*/ | tail -n 2
-rw-r-x---+ 1 root systemd-journal 8.0M Dec 24 05:15 user-xxx.journal

Clear by date: older than X days

Clearing everything older than 10 days:
$ journalctl --vacuum-time=10d
...
Vacuuming done, freed 2.3G of archived journals on disk.

Clear by size: if they exceed X storage

Clearing everything that exceeds 2GB size:
$ journalctl --vacuum-size=2G
...
Vacuuming done, freed 720.0M of archived journals on disk.