2014-02-25 10:13:55 +08:00
|
|
|
# journalctl
|
|
|
|
|
2016-01-07 18:31:27 +01:00
|
|
|
> Query the systemd journal.
|
2021-09-02 15:33:49 -03:00
|
|
|
> More information: <https://manned.org/journalctl>.
|
2014-02-25 10:13:55 +08:00
|
|
|
|
2025-03-07 13:14:54 +02:00
|
|
|
- Show all messages with priority level 3 (errors) from this boot:
|
2014-02-25 10:13:55 +08:00
|
|
|
|
2025-03-07 13:14:54 +02:00
|
|
|
`journalctl {{[-b|--boot]}} {{[-p|--priority]}} 3`
|
2014-02-25 10:13:55 +08:00
|
|
|
|
2022-06-18 21:55:44 +01:00
|
|
|
- Delete journal logs which are older than 2 days:
|
2020-10-12 17:18:41 -04:00
|
|
|
|
2025-03-07 13:14:54 +02:00
|
|
|
`journalctl --vacuum-time 2d`
|
2020-10-12 17:18:41 -04:00
|
|
|
|
2025-03-07 13:14:54 +02:00
|
|
|
- Show only the last N lines and follow new messages (like `tail -f` for traditional syslog):
|
2014-02-25 10:13:55 +08:00
|
|
|
|
2025-03-07 13:14:54 +02:00
|
|
|
`journalctl {{[-n|--lines]}} {{N}} {{[-f|--follow]}}`
|
2014-02-25 10:13:55 +08:00
|
|
|
|
2025-03-07 13:14:54 +02:00
|
|
|
- Show all messages by a specific unit:
|
2014-02-25 10:13:55 +08:00
|
|
|
|
2025-03-07 13:14:54 +02:00
|
|
|
`journalctl {{[-u|--unit]}} {{unit}}`
|
2014-02-25 10:13:55 +08:00
|
|
|
|
2023-12-29 17:00:45 +02:00
|
|
|
- Show logs for a given unit since the last time it started:
|
|
|
|
|
|
|
|
`journalctl _SYSTEMD_INVOCATION_ID=$(systemctl show --value --property=InvocationID {{unit}})`
|
|
|
|
|
2019-07-31 12:45:03 +01:00
|
|
|
- Filter messages within a time range (either timestamp or placeholders like "yesterday"):
|
|
|
|
|
2025-03-07 13:14:54 +02:00
|
|
|
`journalctl {{[-S|--since]}} {{now|today|yesterday|tomorrow}} {{[-U|--until]}} "{{YYYY-MM-DD HH:MM:SS}}"`
|
2019-07-31 12:45:03 +01:00
|
|
|
|
2016-01-07 18:31:27 +01:00
|
|
|
- Show all messages by a specific process:
|
2014-02-25 10:13:55 +08:00
|
|
|
|
|
|
|
`journalctl _PID={{pid}}`
|
|
|
|
|
2016-01-07 18:31:27 +01:00
|
|
|
- Show all messages by a specific executable:
|
2014-02-25 10:13:55 +08:00
|
|
|
|
2018-02-10 15:42:11 +01:00
|
|
|
`journalctl {{path/to/executable}}`
|