journalctl
is a command-line utility in Linux used for querying and displaying messages from the journal, which is a centralized logging system. The journal is managed by systemd-journald
and is part of the larger systemd system and service manager.
Here are some key points about journalctl
:
Here are some key points about journalctl
:
Viewing Logs:
journalctl
is used to query and display messages from the journal.Filtering Options:
journalctl -u <unit>
to view logs for a specific service.Real-time Monitoring:
-f
option to follow the journal in real-time, similar to the tail -f
command for traditional log files.Here are some examples of journalctl
usage:
journalctl
journalctl -u <unit>
journalctl -f
journalctl --since "2023-01-01 00:00:00"
-x
Option:
-e
Option:
journalctl
to immediately exit after displaying the most recent log entries. This is useful for quickly examining recent events without continuously monitoring the journal.journalctl -u
Option:
journalctl -u <unit>
<unit>
with the name of the systemd unit (service) you want to see logs for.journalctl -u myservice
to display logs specifically related to that service.journalctl -t
Option:
journalctl -t <tag>
<tag>
with the specific tag you want to filter by. This is often used by applications or services to categorize their log messages.journalctl -t myapp
to see only those messages.