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 -b -1 -n 50 shows how the last boot ended

Journalctl
~/tips/tip-journalctl-last-boot-end

journalctl -b -1 -n 50

Read the final lines before a reboot or crash to see whether it was a clean shutdown.

After a server came back up on its own, my first question is whether it shut down or just died. The tail of the previous boot answers that.

Combine the previous boot with a line count:

journalctl -b -1 -n 50

A clean shutdown ends with a long list of Stopping ... and Stopped ... lines, then something like Reached target System Power Off or System Reboot and finally the journal stopping. If the last lines are ordinary chatter from some service in the middle of its work, the machine lost power, froze or got reset by a watchdog.

To see who asked for the shutdown, look for logind and the reboot request:

journalctl -b -1 -u systemd-logind -n 20

That usually shows a line about the power key, or about a user starting the reboot.

A missing ending does not always mean a crash. journald syncs to disk at an interval, five minutes by default, so a hard reset can lose the last few minutes of lines. If the boot does not show in journalctl --list-boots at all, your journal is probably not persistent, and then nothing from before the reboot survived.

Further reading: journalctl man page, journald.conf man page (SyncIntervalSec=)

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