Managing systemd journal size

Shell, Guide

April 28, 2024

You may find that /var/log takes up a bit of space on your filesystem. Upon running du -sh /var/log | sort -h to get the size of each file/directory, you see that /var/log/journal takes up over a gigabyte in size (or at least I did). Here’s how to deal with that.

Systemd logs messages to a journal. As per man 5 journald.conf, the default storage directory for this journal is /var/log/journal. You can check/control this logging with the journalctl command.

The first step is to run journalctl --disk-usage, which shows you how much size is taken up by systemd journal logs. Then, you can reduce that however you want by vacuuming the journal. For example, if I want to get disk usage down to 200 megabytes, I use journalctl --vacuum-size=200M. Or, if I want to only keep data from the last week, and delete everything else, I use journalctl --vacuum-time=1week. It’s probably pretty clear, but this command deletes log files, so you’re losing information (which you probably don’t care about since it’s only a historical log). You can then verify that the journal is consistent with journalctl --verify.