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: ForwardToConsole in journald.conf puts the live log on a spare tty

Linux
~/tips/tip-journald-forward-to-console-tty

sudo mkdir -p /etc/systemd/journald.conf.d

Show every new journal line on a spare virtual terminal of the machine.

On a box with a screen attached, I like having one virtual terminal that just shows the log scrolling by. journald can do that by itself with a small drop-in file.

sudo mkdir -p /etc/systemd/journald.conf.d
sudo tee /etc/systemd/journald.conf.d/console.conf <<'EOF'
[Journal]
ForwardToConsole=yes
TTYPath=/dev/tty12
MaxLevelConsole=info
EOF
sudo systemctl restart systemd-journald

Switch to tty12 on the machine (Ctrl+Alt+F12) and every new log line appears there. TTYPath= picks the terminal; without it journald writes to /dev/console. MaxLevelConsole= decides how chatty it gets. info is already the default, and with warning only the problems end up on screen.

The caveat comes straight from the journald.conf man page, and it’s a big one. Forwarding happens synchronously inside journald, so a slow console, like the virtual serial port of a cloud VM, slows journald down, and a console that hangs blocks it, along with every service that’s waiting to log something. The man page advises a journalctl --follow style service sent to the console for production use, and keeping ForwardToConsole=yes for debugging. On a local tty of a home server I’d be fine with it, but I wouldn’t switch it on for a VPS.

Further reading: journald.conf(5) man page

More Linux tips a2query -m rewrite renice -n 10 -p 4242 cat config.yml | xsel -ib xvfb-run -a your-program --some-flag dpkg --get-selections > packages.txt All Linux tips (261) All topics

Link