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-time=2weeks deletes archived journal files older than two weeks

Journalctl
~/tips/tip-journalctl-vacuum-time-weeks

sudo journalctl --vacuum-time=2weeks

Removes archived journal files older than a chosen time span and reports the freed space.

A size limit is not always what I want. Sometimes I just want logs to stop after a fixed time.

--vacuum-time= removes archived journal files older than the timespan. It accepts s, m, h, days, weeks, months and years. Run it once and it prints how much space was freed.

sudo journalctl --vacuum-time=2weeks

Only archived files go, the active one stays. For a permanent rule use MaxRetentionSec= in journald.conf, so you do not have to run the command again.

Further reading: journalctl(1) manual page, systemd.time(7) manual 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