Filter journal entries produced by nginx.service.
Which command is appropriate?
journalctl -u UNIT filters entries associated with a systemd unit.
Detailed explanation
journalctl -u nginx.serviceCorrect. -u nginx.service selects the unit's journal entries.
Correct. -u nginx.service selects the unit's journal entries.
journalctl -t nginx.serviceIncorrect. -t filters a syslog identifier.
Incorrect. -t filters a syslog identifier.
journalctl -p nginx.serviceIncorrect. -p selects priority.
Incorrect. -p selects priority.
journalctl -k nginx.serviceIncorrect. -k selects kernel messages.
Incorrect. -k selects kernel messages.
Try it yourself
An example you can run in a temporary verification environment.
journalctl --help | grep -E -- '-u|--unit' | head -n 1Expected result
unit filterのhelp行Key points
- -u selects a unit
- -t selects an identifier
- Multiple -u filters are possible
Notes
- Environment: systemd journalctl help / journal読取なし
- Command output formatting can vary slightly by distribution or tool version.
- Run the example in a temporary directory or process when possible.
Foundation review
Read the scope first
Check whether the command acts on the current shell, a new process, an existing process, or a file.
Verify the observable result
Use the supplied command and compare the output with the expected result.