/commands/systemd/journalctl-follow-unit-logs
journalctl -u nginx -f: follow the logs of one systemd service
The commands on this page have not been executed by our verification runner yet.updated
- tool
- systemd
- versions
- systemd 2xx
- os
- linux
journalctl -u nginx -f prints the most recent log lines of the nginx.service unit and keeps following new ones, like tail -f; stop with Ctrl+C. -u selects a unit (the .service suffix is optional) and can be repeated, -f follows, and -n 100 sets how many past lines to show first. Reading the system journal of other users' services needs root or membership in the systemd-journal or adm group.
Common forms
journalctl -u nginx -f # follow, starting with the last 10 lines
journalctl -u nginx -n 100 --no-pager # last 100 lines, print and exit
journalctl -u nginx -b # since the current boot
journalctl -u nginx --since "1 hour ago"
journalctl -u nginx --since "2026-10-21 09:00" --until "2026-10-21 10:00"
journalctl -u nginx -u php-fpm -f # two units interleaved
journalctl -u nginx -p err -b # priority err and worse
journalctl --user -u myapp -f # a user service (systemctl --user)Options
| Option | Effect |
|---|---|
| -u, --unit=UNIT | Only entries of this unit (glob patterns allowed, for example -u "nginx*") |
| -f, --follow | Keep printing new entries |
| -n, --lines=N | Show the last N entries (10 with -f when not given) |
| -b, --boot[=ID] | Entries of the current boot, or -b -1 for the previous one |
| -S, --since / -U, --until | Time range: "yesterday", "10 min ago", "2026-10-21 09:00" |
| -p, --priority=LEVEL | emerg, alert, crit, err, warning, notice, info, debug (or a range) |
| -e, --pager-end | Open the pager at the end |
| -x, --catalog | Add explanation texts to known messages |
| -o, --output=MODE | short-iso, short-precise, cat (message only), json, json-pretty |
| --no-pager | Print directly instead of opening less |
| -g, --grep=PATTERN | Only messages matching the regex |
When the unit shows no logs
- The program logs to its own files (nginx writes
/var/log/nginx/error.logby default); the journal then only has systemd's start and stop messages. - You are not root and not in the
systemd-journalgroup: journalctl shows only your own user's entries and says so in a hint. - The journal is volatile (
/run/log/journal) and was lost at reboot; create/var/log/journalor setStorage=persistentinjournald.confto keep logs across boots.
journalctl --disk-usage
sudo journalctl --vacuum-time=2weeks # delete archived entries older than 2 weeksSources
Related pages
flags · systemdjournalctl --since and --until: show logs from a time rangejournalctl --since and --until (-S, -U) limit logs to a time range: dates, today, yesterday, -1h, 30 min ago, time zones. Quoting and interaction with -b.flags · systemdjournalctl -b: logs from the current or a previous boot (-b -1, --list-boots)journalctl -b shows logs of the current boot, -b -1 the previous one, --list-boots all stored boots. Why previous boots are missing and how to keep them.errors · systemdJob for nginx.service failed because the control process exited with error codesystemctl start fails with the control process exited with error code when the start command returned non-zero. Read journalctl -xeu NAME for the cause.commands · systemdsystemctl --failed: list failed services and see whysystemctl --failed lists failed systemd units; systemctl status and journalctl -u show why they failed. Common Result values, reset-failed, and restarting.config · systemdsystemd Restart=on-failure: restart a service automatically when it crashesRestart=on-failure in [Service] restarts a unit when it exits non-zero, crashes or times out. Tune RestartSec and the StartLimitBurst start rate limit.