brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: journalctl _PID=1 shows only what systemd itself said

Journalctl
~/tips/tip-journalctl-pid-one

journalctl _PID=1 -b

Read the service manager's own messages about starts, stops and failures without the services' chatter.

When a boot goes weird I want the service manager’s side of the story first: which units it started, which ones it gave up on. Those lines all come from one process.

On the system journal, PID 1 is systemd. A match on the trusted _PID field keeps only its lines:

journalctl _PID=1 -b

The output is a clean timeline of the boot: Starting nginx.service..., Started ..., Reached target ..., and the lines about failed units and their exit codes. Everything nginx or sshd logged themselves is left out, which makes it much easier to see the order things happened in.

Combine it with a priority to see only the trouble:

journalctl _PID=1 -b -p warning

The same match works for any process while you know its PID, for example journalctl _PID=4211 for a worker you spotted in top. Just keep in mind that PIDs get reused. Old lines with that number may belong to a completely different program from an earlier boot, so add -b when you chase a PID that is not 1.

Further reading: systemd.journal-fields man page, journalctl man page

More Journalctl tips journalctl -k -g 'killed process' --since "2 days ago" ls -lh /var/log/journal/*/*.journal~ Storage=volatile sudo journalctl --setup-keys journalctl -F _KERNEL_SUBSYSTEM All Journalctl tips (81) All topics

Link