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: journalctl --vacuum-size caps how much log space you keep

Journalctl
~/tips/tip-linux-journalctl-vacuum

journalctl --disk-usage

Shrinks the systemd journal to a size you pick by deleting the oldest logs.

Systemd logs add up quietly. If your root disk is smaller than you would like, the journal is worth a look.

First see how much space it uses:

journalctl --disk-usage

If that number annoys you, trim it to a size you choose:

sudo journalctl --vacuum-size=200M

This deletes the oldest archived journal files until the total is under 200 MB. There is also --vacuum-time=2weeks, which removes archived journal files older than that instead.

Two caveats. It only touches archived files, so the number may stay above your target until the active file rotates. And deleted logs are gone for good, so do not trim before you have looked at the problem you are chasing. For a permanent limit, set SystemMaxUse=200M in /etc/systemd/journald.conf and restart systemd-journald. I prefer the setting over repeating the command.

On a small VM or a Raspberry Pi with a tiny SD card, disk space is not free, and logs are the one thing that grows without anyone asking for it. A fixed cap in the config file is boring, and boring is what I want from a logging setup.

Further reading: journalctl man page, journald.conf man page, On this site: tail -F keeps following a log after logrotate renames it, On this site: systemctl edit changes a service without touching the original

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