Skip to content
Latchkey

journalctl Command Reference: Flags, Usage & CI Examples

journalctl reads and filters the systemd journal log.

journalctl queries the structured logs systemd collects from services and the kernel. On self-hosted runners it is the first stop when a managed service misbehaves.

Common flags and usage

  • -u <unit>: show logs for one unit
  • -f: follow new log lines (like tail -f)
  • --since "10 min ago": filter by time
  • -n <N>: show the last N lines
  • -p err: filter by priority (e.g. error and worse)
  • -b: show logs from the current boot only

Example

shell
systemctl is-active --quiet myservice \
  || journalctl -u myservice -n 200 --no-pager

In CI

When a self-hosted-runner service fails to come up, dump journalctl -u <unit> -n 200 --no-pager so the failing logs land in the CI output. Add --no-pager so it does not block waiting for an interactive pager.

Key takeaways

  • journalctl reads the systemd journal, filtered by unit, time, or priority.
  • journalctl -u <unit> --no-pager surfaces a failed service log in CI.
  • It only sees systemd-managed logs, so it needs systemd present.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →