Skip to main content
Kill -9 Club
Sign in

journalctl

systemdPackage: systemd

Reads the systemd journal, by unit (-u), by period (--since), by boot (-b), live (-f). It is where a service's output went when it writes to no file.

What its options do in the lessons

From the same glossary the lessons render under their commands, so the two cannot disagree.

journalctl -u
Shows only the messages from that unit.
journalctl -f
Follows the journal and prints new entries as they arrive.
journalctl -n
Limits output to that many of the most recent entries.
journalctl -e
Jumps straight to the end of the journal.
journalctl -b
Limits to one boot: -b the current one, -b -1 the one before.
journalctl -k
Shows kernel messages only (the equivalent of dmesg). AppArmor denials land here, in the kernel’s log rather than in the affected service’s.
journalctl --no-pager
Opens no interactive pager: output goes straight to standard output. Essential in a script, where a pager would wait for a keypress nobody makes and hang the run.
journalctl --list-boots
Lists the recorded boots, which is where the identifiers for -b come from.
journalctl --since
Shows only entries from a date or expression onwards (--since '-2 hours').
journalctl --until
The upper bound, mirroring --since.
journalctl -p
Filters by syslog priority (-p err: errors and worse).
journalctl -x
Adds an explanatory note from the systemd catalogue under certain messages, saying what the event means and what can be done about it.
journalctl -o
The output format. -o verbose shows every journal field, including the ones the normal format hides; -o cat shows the message alone.
journalctl --utc
Prints timestamps in Coordinated Universal Time. What you want in order to line the journal up against a source already writing in UTC, with no conversion done in your head.
journalctl -t
Filters on a program’s syslog identifier, useful for a tool with no unit of its own (-t sudo).
journalctl --disk-usage
Reports how much disk the journal occupies.
journalctl --vacuum-size
Deletes the oldest archived files until the journal fits the given size.
journalctl --vacuum-time
Deletes archives older than the given age.
journalctl --flush
Asks the daemon to flush the journal from /run/log/journal into /var/log/journal, once persistent storage exists. The option belongs to journalctl, not to the daemon: systemd-journald is not invoked by hand.

Lessons that teach it