eolas/zk/journald.md

61 lines
1.1 KiB
Markdown
Raw Normal View History

2022-08-21 09:00:05 +01:00
---
2023-02-10 18:22:04 +00:00
tags: [systems-programming]
2022-08-21 09:00:05 +01:00
---
# `journald`
2024-02-17 11:57:44 +00:00
`journald` is a program that comes as default with [systemd](systemd.md).
It is a service fror collecting and storing system-level log data. I keeps a
2024-02-17 11:57:44 +00:00
track of all [kernel](The_Kernel.md) processes. It is
invaluable when tracing the source of problems and errors that may arise on the
system level. It keeps a track of all kernal processes.
2022-08-21 09:00:05 +01:00
2024-02-16 16:14:01 +00:00
![](/img/journald.png)
2022-08-21 09:00:05 +01:00
2022-09-06 13:26:44 +01:00
## `journalctl`
2022-08-21 09:00:05 +01:00
We use `journalctl` to access the logs. The command by itself outputs the entire
log which will be huge and hard to scroll through. We can refine the results
with modifiers.
2022-08-21 09:00:05 +01:00
### View logs for a specific process with pid
```bash
journalctl _PID=1234
```
### View logs for a specific time period
2022-09-06 13:26:44 +01:00
This can be really helpful since you can bracket the most recent events which
will be more memorable.
2022-08-21 09:00:05 +01:00
```bash
journalctl -S -1h
```
### View logs for a specfic systemd unit
2022-09-06 13:26:44 +01:00
2022-08-21 09:00:05 +01:00
```bash
2023-01-18 19:52:45 +00:00
journalctl -u [unit_name] -e
2022-08-21 09:00:05 +01:00
```
2022-09-06 13:26:44 +01:00
### View boot logs
2022-08-21 09:00:05 +01:00
```bash
journalctl -b
```
2022-09-06 13:26:44 +01:00
#### Identify specific boot
2022-08-21 09:00:05 +01:00
```bash
journalctl --list-boots
2022-08-21 09:30:04 +01:00
```
### List only kernel entries to the journal
```bash
journalctl -k
2022-09-06 13:26:44 +01:00
```