Skip to content

journalctl — reading systemd journal logs without losing your place

The journal is the first thing you look at when something is wrong, and the last thing you remember the right flags for. Here is the operator-grade cheat sheet.

The systemd journal is the first place you look when something is wrong, and the last place you remember the right flags for. This article is the reference we hand new operators on day one. It covers the queries that come up daily — by unit, by time, by priority, by boot, by pattern — and the small handful of admin-side commands that keep the journal from filling the disk. For the deeper patterns (structured queries, retention by priority, forwarding to remote stores), the dedicated deep-dive article is the next step.

How to verify

Inventory the state of journald on the host.

journalctl --disk-usage
journalctl --list-boots
systemctl status systemd-journald --no-pager
cat /etc/systemd/journald.conf | grep -v '^#' | grep -v '^$'
ls -la /var/log/journal/ 2>/dev/null

/var/log/journal/ exists when persistent storage is configured. Without it, journald only buffers in /run/log/journal/ and the log disappears at every reboot.

What’s happening

systemd-journald is the daemon that ingests log streams from every service started under systemd, plus syslog-format messages, plus the kernel ring buffer. It writes them to a binary journal file with structured fields (unit, priority, pid, transport, message, and any custom fields the application chose to emit). journalctl is the front-end for querying.

The reason the journal is more useful than plain text logs is structure. Every entry has fields — not just message. You can filter by _SYSTEMD_UNIT=nginx.service, by PRIORITY=err, by _PID=12345, by _BOOT_ID=<id>. You can output in JSON for machine processing. The text grep that took five minutes against /var/log can be a one-second query against the journal once you know the field names.

Persistent storage matters. The default on a fresh install often only keeps the journal in memory (/run/log/journal/), wiped on reboot. The fix is to create /var/log/journal/, which journald automatically detects and uses for persistence. We do this on every host.

The procedure

  1. Make the journal persistent if it is not already.

    sudo mkdir -p /var/log/journal
    sudo systemd-tmpfiles --create --prefix /var/log/journal
    sudo systemctl restart systemd-journald
    journalctl --disk-usage

    The first journalctl --disk-usage after this should show actual MB/GB, not just “(in /run)”. To bound the size:

    sudo tee /etc/systemd/journald.conf.d/00-retention.conf > /dev/null <<'EOF'
    [Journal]
    SystemMaxUse=2G
    SystemKeepFree=500M
    SystemMaxFileSize=128M
    SystemMaxFiles=20
    ForwardToSyslog=no
    Compress=yes
    Seal=yes
    EOF
    sudo systemctl restart systemd-journald

    Seal=yes makes the journal tamper-evident with a forward-secure signature; useful for compliance.

  2. Read by unit.

    journalctl -u nginx                    # all entries for nginx, oldest first
    journalctl -u nginx -r                 # newest first
    journalctl -u nginx --since today
    journalctl -u nginx --since "2 hours ago"
    journalctl -u nginx --since "2026-06-02 09:00" --until "2026-06-02 10:30"
    journalctl -u nginx -n 50              # last 50 entries
    journalctl -u nginx -f                 # follow (like tail -f)

    -u accepts globs: journalctl -u 'nginx*' matches nginx.service, nginx-rotate.service, etc.

  3. Read by priority. systemd uses the standard syslog severities 0–7.

    journalctl -p err                      # err and above
    journalctl -p warning..err             # warning + err only, not crit/alert
    journalctl -p err -u nginx --since today

    Levels: emerg, alert, crit, err, warning, notice, info, debug.

  4. Read by boot. Useful when you reboot and want to know what happened this boot.

    journalctl -b                          # this boot
    journalctl -b -1                       # previous boot
    journalctl -b -1 -u app
    journalctl --list-boots
  5. Search by pattern. -g (grep) does a regex match on the message field.

    journalctl -u nginx -g 'connection reset|broken pipe' --since today
    journalctl -k -g 'oom-kill'            # kernel ring buffer for OOM events

    -k restricts to kernel messages. The OOM-killer logs to the kernel ring buffer with a distinct prefix.

  6. Output formats for machine processing.

    journalctl -u nginx --since today -o json | jq '.MESSAGE'
    journalctl -u nginx --since today -o json-pretty | head -30
    journalctl -u nginx --since today -o cat       # just the message, no metadata
    journalctl -u nginx --since today -o short-iso # ISO timestamps

    JSON output is what you pipe into jq, vector, or your central log pipeline.

  7. Find which services produced the most logs. A noisy service often signals a bug or a misconfiguration.

    sudo journalctl --since today \
      | awk '/[[:digit:]]+:[[:digit:]]+/ { sub(/\[.*\]/, ""); print $5 }' \
      | sort | uniq -c | sort -rn | head

    For a more accurate count, journalctl --since today -o json --no-pager | jq -r ._SYSTEMD_UNIT | sort | uniq -c | sort -rn | head.

  8. Verify journal integrity. If Seal=yes is set, you can verify the journal has not been tampered with.

    sudo journalctl --verify
    sudo journalctl --vacuum-size=500M     # delete oldest entries to fit under 500M
    sudo journalctl --vacuum-time=14d      # delete entries older than 14 days
  9. Quick triage for a freshly broken host.

    systemctl --failed
    journalctl -p err -b --no-pager | tail -100
    journalctl -k -b -p warning --no-pager | tail -50

    That sequence — failed units, recent errors, recent kernel warnings — will surface the cause of >80% of “what just happened” tickets.

Operational notes

  • journalctl without arguments prints the entire journal from the oldest entry. On a busy host this is enormous; almost always use a filter.
  • journalctl -u <unit> requires the exact unit name including the suffix (.service, .timer, .socket). Globs are accepted but case-sensitive.
  • The default time zone for --since/--until is the host’s local TZ. For correlation across a fleet, use --utc to normalize.
  • Forwarding to syslog (ForwardToSyslog=yes) doubles every entry on disk; disable unless you need rsyslog/journald coexistence.
  • Long-running journalctl -f can consume RAM as the journal grows; use --lines=0 to start from the present.
  • A corrupted journal file (rare, but happens) is rotated by journald automatically; the bad file is renamed to *.journal~ and a new file opens. Worth knowing when free space disappears.

In our fleet, the journal is persistent on every host, retention is bounded, structured fields are forwarded to a central Loki or OpenSearch via promtail or vector, and the host-level journal stays for local triage. That combination — local journal for the on-host debugger, central store for fleet-wide analysis — is the logging baseline of Managed Operations.