03 September 2018 | 1 min read

Clean-up journal logs

Pfu.. seem size limit of journal log are almost reaching 2 GB

$ du -h /var/log/journal/ | tail -n 1
1.8G    /var/log/journal/

I want to clean this logs. Now flush all journal data from /run into /var

$ journalctl --flush

Check and verify our logs condition are PASS or FAILED

$ journalctl --verify

How was the result? Looking good? let’s free some space of archived journal files and only store 1 week logs

$ journalctl --vacuum-size=30M
$ journalctl --vacuum-time=1weeks

By default the global journal configuration of The maximum size of the persistent journal aka SystemMaxUse are commented

$ grep SystemMaxUse /etc/systemd/journald.conf
#SystemMaxUse=

You can uncommenting and put some value, eg SystemMaxUse=30M, but I prefer to use the drop-in snippets configuration override mechanism rather than editing the global configuration file.

$ sudo mkdir -p /etc/systemd/journald.conf.d/ 
$ sudo touch /etc/systemd/journald.conf.d/00-journal-size.conf 
$ sudo bash -c 'cat > /etc/systemd/journald.conf.d/00-journal-size.conf  << 'EOF'
[Journal]
SystemMaxUse=30M
EOF'

You can change the value 30M to what ever size you prefered. To apply the new limit, you need to restart the services as superuser.

$ systemctl status systemd-journald.service
$ sudo systemctl restart systemd-journald.service
$ systemctl status systemd-journald.service

Robbi Nespu | Bash, Fedora, Linux, SystemD


Discussion and feedback