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 -u takes a wildcard to read a whole family of units

Journalctl
~/tips/tip-journalctl-unit-glob

journalctl -u 'php*-fpm.service' --since today

Read all instances of a template service or every matching unit in one command.

Template units like [email protected] or a handful of php8.x-fpm versions make -u with an exact name annoying. It takes a shell style pattern instead.

Quote the pattern so your shell leaves the star alone:

journalctl -u 'php*-fpm.service' --since today

journalctl matches the pattern against the units it knows and merges their logs in time order. With a template that is the easiest way to see every instance at once. Take a socket activated [email protected], which creates one instance per connection with a long generated name:

journalctl -u 'echo@*'

That returns the lines of every connection’s instance, and I like that you never have to copy a single instance name.

The man page says the pattern is compared with the unit names found in the journal, so old instances that no longer exist still match. That cuts both ways: a loose pattern like 'php*' also pulls in any other unit whose name starts with php, now or in the past. Run journalctl -F _SYSTEMD_UNIT | grep php first if you are not sure what your pattern will catch.

Further reading: journalctl man page

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

Link