GuidesRunning & maintaining

journalctl: view, filter and follow systemd logs

journalctl commands with examples: -u, -f, -n, --since, -b -1, -p, -g, --user for user services, crash loops, and vacuuming a journal that fills the disk.

December 4, 2026The Everpod team
The short answer

journalctl reads the systemd journal, where Linux keeps the logs of every service. The commands you will use most: journalctl -u NAME for one service, -f to follow it live, -n 50 for the last 50 lines, -e to open at the end, --since "1 hour ago" for a time window, -b -1 for the previous boot (only with a persistent journal), and -g PATTERN to grep. A service you installed for your own account, as OpenClaw’s gateway is, needs journalctl --user -u NAME; without --user you see nothing. If you see only a few lines as a normal user, join the systemd-journal group or use sudo. As of December 2026 the manual describes systemd 262; Ubuntu 24.04 ships 255 and Ubuntu 26.04 ships 259, and every command here works on both.

The commands, with examples

Every option below is from the journalctl manual. Options combine freely, so -u, --since and -p together narrow to one service, one window and one severity at once.

You wantCommand
One service’s logs
journalctl -u nginx
Follow new lines live (Ctrl+C stops)
journalctl -u nginx -f
The last 50 lines
journalctl -u nginx -n 50 (plain -n means 10)
Open at the end, in the pager
journalctl -u nginx -e
Newest first
journalctl -u nginx -r
A time window
journalctl --since "2026-12-04 09:00" --until "2026-12-04 10:30"
Relative time
journalctl --since "1 hour ago", --since today, --since yesterday --until today
This boot only
journalctl -b
The boot before this one
journalctl -b -1
Which boots are stored
journalctl --list-boots
Errors and worse
journalctl -p err -b
Kernel messages (like dmesg)
journalctl -k
Lines matching a pattern
journalctl -u nginx -g "timeout|refused"
Just the message text
journalctl -u nginx -o cat
One JSON object per line
journalctl -u nginx -o json
Print without the pager
journalctl -u nginx -n 100 --no-pager
Explanations for known messages
journalctl -u nginx -x

A few details the short forms hide:

-p err misses most crashes of a program you run as a service

This is the trap with the priority filter. When a service writes to stdout or stderr, systemd sends both to the journal at level info unless the unit sets otherwise (the systemd.exec manual: SyslogLevel= “Defaults to info”, and StandardError= inherits standard output, which goes to the journal). A Node or Python process that dies with a stack trace on stderr has therefore logged it at info, and journalctl -u NAME -p err will not show it. Only a program that prefixes its lines with a syslog level, or logs to the journal directly, gets a real priority. For a coding agent’s gateway or server, search the text instead:

journalctl -u NAME -b -g "error|exception|fatal|traceback"
Copied

A service that runs as your user: --user

Agents that install a background service for you usually make it a systemd user service, owned by your account rather than the system: OpenClaw’s openclaw-gateway and Hermes’s hermes-gateway are both of this kind. Their logs live in your user journal, and plain journalctl -u looks in the system’s units, so it finds nothing:

journalctl --user -u openclaw-gateway -f
Copied

There is a condition. The manual says --user “only works if persistent logging is enabled, via the Storage= setting in journald.conf”, because separate per-user journal files exist only on disk: the journald.conf manual says splitting by user “is only available for journals stored persistently.” With an in-memory journal, everything goes into one system file. Reading the two manuals together, a user unit’s lines are then still there, but only an account that can read the whole journal can reach them, with the --user-unit option:

sudo journalctl --user-unit openclaw-gateway -n 100
Copied

The same command is how an admin reads another account’s user service. The next section shows how to check, and turn on, the persistent journal. Setting up the service so it survives logout and reboot, which is lingering, is covered in keeping a user service running on a server.

Previous boots need a persistent journal

The journal is kept either in memory under /run/log/journal, lost at every reboot, or on disk under /var/log/journal. If you run journalctl -b -1 after a crash and the server reboot and get nothing, journalctl --list-boots shows a single boot: the journal was in memory.

The Storage= setting decides. With auto, logs go to disk if /var/log/journal exists and to memory if not. systemd’s two manual pages describe the default slightly differently: the journald service page says logs persist “if /var/log/journal/ exists during boot”, while journald.conf says the default is persistent, a value “determined at compilation time”, so your distribution’s build decides. Debian has kept the journal on disk by default since Debian 11, its release notes say, and Ubuntu’s systemd package began creating /var/log/journal at install in Ubuntu 18.04 (Launchpad bug 1618188). A trimmed image or a container can still differ, so on any machine the quick check is whether the directory exists:

ls -d /var/log/journal
Copied

If it does not, these are the steps systemd’s manual gives, followed by a restart of journald, which its manual calls safe (stopping it is not recommended):

sudo mkdir -p /var/log/journal
sudo systemd-tmpfiles --create --prefix /var/log/journal
sudo systemctl restart systemd-journald
Copied

Only boots from then on are kept. To make it explicit regardless of the directory, set Storage=persistent in a drop-in, as in the disk-size section below.

Why a normal user sees almost nothing

Run journalctl without sudo as an ordinary user and you may get only your own messages, with this notice:

Hint: You are currently not seeing messages from other users and the system.
      Users in groups 'adm', 'systemd-journal' can see all messages.
      Pass -q to turn off this notice.
Copied

or, where you have no journal of your own, No journal files were opened due to insufficient permissions. By the manual, “only root and users who are members of a few special groups are granted access”: members of systemd-journal, adm and wheel can read every journal file. The groups named in the hint vary by distribution. To give an account read access, add it to systemd-journal, the group that owns the journal files, then log out and back in:

sudo usermod -aG systemd-journal "$USER"
Copied

adm and wheel also work, but the manual notes they traditionally carry additional privileges set by the distribution. Think before granting any of them to the account a coding agent runs under: the journal holds every service’s output, including anything a program printed that it should not have.

A service that keeps restarting

A gateway or server that crashes on start, with Restart=on-failure or always set, is restarted after 100 ms by default. systemd allows five starts in ten seconds (DefaultStartLimitBurst=5, DefaultStartLimitIntervalSec=10s in the manager defaults); after that it stops trying and logs:

NAME.service: Start request repeated too quickly.
Copied

systemctl status then shows Active: failed (Result: start-limit-hit). That line is the consequence, not the cause, and it is usually the last thing on screen. The cause is the first failure, a few lines further up:

  1. systemctl status NAME (add --user for a user service) to confirm the state and see the exit code.
  2. Read back far enough to reach the first start of the loop:
    journalctl -u NAME -b -n 200 --no-pager
    Copied
    The program’s own last lines before systemd reports it exited are the error: a missing file, a port already in use, a bad config value, an expired key.
  3. Fix that, then clear the counter and start again; the unit manual says reset-failed flushes the restart rate counter:
    systemctl reset-failed NAME
    systemctl start NAME
    Copied
    (With sudo for a system service, or --user after systemctl for a user one.)

For OpenClaw’s gateway specifically, the errors that cause this loop and their fixes are in the gateway crash-loop guide.

Two services at once, and handing logs to an agent

Repeat -u to follow several units in one stream. The manual combines matches on the same field with OR, so this interleaves both by time:

journalctl -f -u nginx -u myapp
Copied

The same works for user units with --user in front. It is the quickest way to see a reverse proxy refuse a request at the moment the app behind it logs why.

When you want a coding agent to diagnose a service, give it a bounded, plain-text slice rather than a live stream: -f never exits on its own, which suits a person watching, not a command whose output an agent reads once it ends. Something like this is the useful shape, and Claude Code, Codex or OpenCode can run it themselves on the server:

journalctl -u NAME --since "30 min ago" --no-pager -o short-iso
Copied

-o cat drops timestamps and host names when only the message matters, and -o json gives one object per line with every field (the unit, the PID, the priority) for a script or jq. Jobs started by cron are different: cron does not give each job a unit of its own, so -u cannot pick one out (on Ubuntu the daemon itself is cron.service, so journalctl -u cron shows the daemon’s own lines); the crontab guide covers where their output goes.

Keeping the journal from filling a small disk

See what it uses now:

journalctl --disk-usage
Copied

By default journald caps a persistent journal at 10% of the file system and keeps 15% free, each capped at 4 GB. On a 20 GB server that is about 2 GB of logs, and an agent service that crash-loops or logs at debug level reaches it quickly. To free space now, these commands permanently delete old logs, oldest first, until what is left fits in 500 MB. Vacuuming only removes archived journal files, never the ones being written, so --rotate comes first: it archives the current files, which makes their contents deletable too. Save anything you still need to a file first:

sudo journalctl --rotate
sudo journalctl --vacuum-size=500M
Copied

or, by age, deleting everything older than two weeks, sudo journalctl --vacuum-time=2weeks. Sizes take K, M, G and T; times take s, m, h, days, weeks, months and years.

Vacuuming is a one-off; a limit makes it permanent. The journald.conf manual recommends a drop-in file over editing the main one, named with a number from 60 to 90 when it lives in /etc so it wins over the distribution’s own. This creates /etc/systemd/journald.conf.d/60-size.conf (and overwrites it if it exists) with a 500 MB cap, a persistent journal and a month’s retention, then restarts journald to apply it:

sudo mkdir -p /etc/systemd/journald.conf.d
printf '[Journal]\nStorage=persistent\nSystemMaxUse=500M\nMaxRetentionSec=1month\n' | sudo tee /etc/systemd/journald.conf.d/60-size.conf
sudo systemctl restart systemd-journald
Copied

SystemMaxUse= is the cap on disk; MaxRetentionSec= is off by default and drops entries older than the age you give. Leave out the retention line if size alone is enough. The journal is rarely the only thing filling a small disk, but it is the one that grows without anyone noticing.

Versions

The freedesktop.org manuals track the newest systemd, 262 as of December 2026. Servers run older releases: Ubuntu 24.04 ships systemd 255 (255.4-1ubuntu8.18 on packages.ubuntu.com) and Ubuntu 26.04 ships 259 (259.5-0ubuntu3.4). Every option on this page exists in both. Check yours with journalctl --version, and read man journalctl on the server for the exact options your version has. One difference: reloading journald’s config with SIGHUP arrived in systemd 258, so on Ubuntu 24.04 apply a config change with a restart, as above.

Run Claude Code, Codex, OpenCode, Pi, Hermes or OpenClaw on an always-on developer pod.

A developer pod is a permanent cloud computer (VPS), set up and secured for you, with your pick of Claude Code, Codex, OpenCode, Pi, Hermes and OpenClaw installed. Run more agents at once than your laptop can hold, and keep them working when it’s closed. From $24 a month, built in about ten minutes.