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: a persistent journalctl history needs /var/log/journal to exist

Journalctl
~/tips/tip-journalctl-persistent-storage-flush

sudo mkdir -p /var/log/journal

Makes the journal survive reboots by creating the directory journald uses for disk storage.

Logs that vanish at reboot are useless for finding out why the machine rebooted.

sudo mkdir -p /var/log/journal
sudo systemd-tmpfiles --create --prefix /var/log/journal
sudo journalctl --flush

With the default Storage=auto, journald writes to disk only when /var/log/journal exists, otherwise it keeps logs in /run, which is lost at reboot. The tmpfiles command sets the right ownership and group, and --flush moves the current runtime logs to the new location. Some distributions already ship the directory, so check with ls /var/log/journal first. You can also set Storage=persistent in /etc/systemd/journald.conf. Check the result with journalctl --list-boots after the next reboot, which should now list the earlier boots too.

Further reading: journald.conf 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