Pcornel
Linux · Logging

systemd-journald

Cheat sheet · https://pcornel.dk/topic.php?topic=364

Back to the Topic

Answer

systemd-journald collects the output of every service, syslog messages and kernel messages into an indexed journal, queried with journalctl.

Remember

The journal survives a reboot only if /var/log/journal exists. Old entries are removed by size limits, and bursts are dropped by rate limiting. journalctl starts at the oldest entry: filter by unit, boot and time. A service writing to its own log file is not in the journal.

First checks

  • journalctl -u <unit> -b — one unit, this boot.
  • journalctl -b -1 -p err — errors from the previous boot.
  • journalctl --since "1 hour ago" — a time window.
  • journalctl -k — kernel messages.
  • journalctl --list-boots — which boots the journal still holds.
  • journalctl --disk-usage — space used.

Commands

journalctl -u <unit> --since '<time>'
Service-specific journal entries in a time window.
journalctl -u <unit> --since "-1h"
Query systemd journal.
journalctl -b -u <unit> --since ...
journalctl --disk-usage
journalctl --vacuum-size=1G
journalctl --verify
journalctl --rotate
journalctl
journalctl -u nginx
journalctl -b
journalctl -p err
journalctl --since "1 hour ago"
journalctl -f
journalctl -k
journalctl -u nginx -b -p warning
journalctl --vacuum-time=2weeks

Verify in this order

service writes to output or syslog → journald receives it → not dropped by rate limit → stored (volatile or persistent) → still within size and age limits → found by the right unit, boot and time filter

Where it usually breaks

First mismatch in persistent unit/config/generator → dependency/order graph → systemd state → process/cgroup → socket/resource dependency → journal → consumer check; preserve identity/native diagnostic/pre-state before mutation.

Read-only verification commands unless stated otherwise. Confirm syntax for your platform and release. Full reference: https://pcornel.dk/topic.php?topic=364

Confirmation

Confirm action

Continue?