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.
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 want | Command |
|---|---|
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:
-utakes a pattern.journalctl -u 'openclaw*'matches every unit whose name starts that way, and the match also brings in systemd’s own messages about the unit (started, stopped, failed), which is usually what you want when something will not start.-eis not “everything”. It jumps to the end inlessand quietly implies-n 1000and-b 0, so older lines and earlier boots are not loaded. Add-n allor a--sinceif you need to scroll further back.- Time formats.
--sinceand--untiltakeYYYY-MM-DD HH:MM:SS(a missing time means midnight), the wordsyesterday,today,tomorrowandnow, and relative times such as-30mor"2h ago"(the systemd.time manual has the full syntax). Quote anything with a space. -pincludes everything more severe. The levels areemerg(0),alert,crit,err,warning,notice,infoanddebug(7);-p errshows err, crit, alert and emerg. AFROM..TOpair limits it to a range.-gis case-insensitive only when the pattern is all lowercase.-g errormatches “Error”;-g Errordoes not match “error”. It is a PCRE2 regular expression on the message text, and has existed since systemd 237.
-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"CopiedA 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 -fCopiedThere 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 100CopiedThe 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/journalCopiedIf 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-journaldCopiedOnly 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.Copiedor, 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"Copiedadm 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.Copiedsystemctl 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:
systemctl status NAME(add--userfor a user service) to confirm the state and see the exit code.- Read back far enough to reach the first start of the loop: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.
Copiedjournalctl -u NAME -b -n 200 --no-pager - Fix that, then clear the counter and start again; the unit manual says
reset-failedflushes the restart rate counter:(With
Copiedsystemctl reset-failed NAME systemctl start NAMEsudofor a system service, or--useraftersystemctlfor 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 myappCopiedThe 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-isoCopied-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-usageCopiedBy 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=500MCopiedor, 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-journaldCopiedSystemMaxUse= 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.