journalctl flags & options
-u, --unit
Show logs for a specific systemd unit.
journalctl -u nginx
journalctl -u ssh -u docker
-f, --follow
Stream new log entries in real time like tail -f.
journalctl -f
journalctl -fu nginx
-n
Show only the last N log entries.
journalctl -n 50
journalctl -u mysql -n 100
--since, --until
Filter logs by time range.
journalctl --since "2024-01-15 09:00:00"
journalctl --since "1 hour ago"
journalctl --since "2024-01-15" --until "2024-01-16"
-p, --priority
Filter by log priority level (emerg, alert, crit, err, warning, notice, info, debug).
journalctl -p err
journalctl -p warning -u nginx
-b
Show logs from a specific boot, where 0 is current boot and -1 is previous.
journalctl -b
journalctl -b -1
--no-pager
Print output directly without a pager, useful for scripting.
journalctl -u nginx --no-pager
-o, --output
Control the output format (short, json, json-pretty, verbose, cat).
journalctl -u nginx -o json-pretty
journalctl -o cat -n 20