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 --no-pager sends the output straight to the next command

Journalctl
~/tips/tip-journalctl-no-pager-pipe

journalctl -u ssh --no-pager | grep -c Accepted

Prints the output directly instead of opening a pager, which suits scripts and pipes.

In a script or behind a pipe, a pager waits for a key press and nothing happens.

--no-pager prints everything to standard output and exits. That is what you want when you count lines, feed another tool or save a copy to a file. The example counts the accepted logins of the SSH service.

journalctl -u ssh --no-pager | grep -c Accepted

When the output goes to a pipe, journalctl already skips the pager on its own, but I put the flag in scripts anyway, so the intent is visible.

Further reading: journalctl(1) 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