brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: SystemMaxFileSize in journald.conf decides how much journalctl vacuum frees at once

Journalctl
~/tips/tip-journalctl-max-file-size

sudo tee /etc/systemd/journald.conf.d/50-filesize.conf <<'EOF'

Control the size of each journal file, and with it how coarse cleanups are.

journald never deletes single lines. It deletes whole archived files. So the size of each file decides how much history disappears in one go when a limit is hit.

The man page says the default is one eighth of SystemMaxUse=, capped to 128M, which usually leaves about seven archived files as history. On a box with a big limit that means each cleanup step throws away a big chunk at once. Smaller files make it smoother:

sudo tee /etc/systemd/journald.conf.d/50-filesize.conf <<'EOF'
[Journal]
SystemMaxUse=1G
SystemMaxFileSize=32M
EOF
sudo systemctl restart systemd-journald

Now journald rotates every 32 MB, and when the 1 GB total is reached it removes the oldest 32 MB file. You can check the effect with:

ls -lh /var/log/journal/*/

I find this worth setting together with SystemMaxUse= whenever you raise that limit a lot.

Very small files have a cost too. Every file has its own header and index, so lots of tiny files make searches across the whole journal slower and waste some space. I would not go much below 16 MB. And the setting only affects files created after the restart; existing ones stay as they are until they get rotated and vacuumed.

Further reading: journald.conf man page

More Journalctl tips journalctl -k -g 'killed process' --since "2 days ago" journalctl _PID=1 -b ls -lh /var/log/journal/*/*.journal~ Storage=volatile sudo journalctl --setup-keys All Journalctl tips (81) All topics

Link