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 twice merges the logs of two services in time order

Journalctl
~/tips/tip-journalctl-multiple-units-interleaved

journalctl -u nginx -u mariadb --since "30 min ago" -f

Shows the logs of several services in a single time-ordered stream.

When a web app and its database disagree, I want both logs in one timeline.

journalctl -u nginx -u mariadb --since "30 min ago" -f

Each -u adds a unit to the filter, and the output is interleaved by timestamp, so cause and effect appear next to each other. -f keeps following new lines. You can add a pattern such as -u 'php*' to match several units. Quote it so the shell does not expand it. Add -p warning to cut the noise further. The default format shows the program name that logged each line, which can differ from the unit name.

Further reading: journalctl manual 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