Skip to content

Did you know?

journalctl -b -1 shows the logs from before the last reboot.

The fastest way to find out why a server crashed or rebooted.

Explained

When a machine rebooted unexpectedly, the interesting messages are in the previous boot. -b selects a boot: -b or -b 0 is the current one, -b -1 the one before, -b -2 the one before that.

journalctl -b -1 -p err
journalctl -b -1 -e

-p err shows only errors and worse; -e jumps to the end, where the last messages before the reboot are. List the boots the journal knows about:

journalctl --list-boots

This only works if the journal is persistent, that is, stored on disk in /var/log/journal. Without that directory, logs are kept in memory and lost at reboot. Ubuntu enables it by default. To enable it elsewhere:

sudo mkdir -p /var/log/journal
sudo systemctl restart systemd-journald

Keep an eye on its size with journalctl --disk-usage.

Learn more

← All tech tips · Suggest a fix

Back to top