GRABCONSOLE(8)
π GRABCONSOLE(8) β the grabconsole program π
okay bestie, welcome to the grabconsole page. Itβs short, itβs powerful, itβs giving tiny-but-mighty utility energy β¨
πΈ SYNOPSIS πΈ
grabconsole file [command ...]
β¨ DESCRIPTION β¨
So grabconsole redirects messages to /dev/console to the given file, and that file must be the slave side of a pseudoterminal. No cap. It may be specified as either a filename or a file descriptor. Then it execs the given command, if any. Slay.
This is useful to log such messages to disk when syslogd is not running but some services log through syslog. Literally the exact save.
π EXAMPLE π
Hereβs the vibe:
$ cat /service/console-log/run
#!/bin/sh
exec \
ptyget \
sh -c '
exec 6<&- 7<&- &&
setblock +4 &&
grabconsole 5 &&
exec <&4 \
setuidgid loguser \
multilog t ./main'
Break it down, bestie:
ptygetallocates a pseudoterminal.setblocksets the master side to be blocking β so a process reading the master side will wait for input instead of gettingEAGAINwhen there is currently no input to be read. Thatβs the whole point, periodt.grabconsoleredirects/dev/consolemessages to the slave side of the pseudoterminal.multilog, running asloguser, reads console messages from the master side of the pseudoterminal and writes them to./main.
β οΈ note note note: this may cause problems with console logins unless logins use a different device referring to the console, such as /dev/tty1 on Linux. So like, be aware π
π¦ XCONSOLE VIBE π¦
This line:
xterm -e sh -ec 'grabconsole 0; setblock +0; exec cat'
is equivalent to xconsole. Thatβs it. Thatβs the equivalence. Iconic.
π sign-off π
Source/version and date check: the footer is literally The grabconsole program() β no version number, no date, just mysterious minimal queen behavior. Byeee bestie, go redirect some console messages π«Άβ¨
π¦ where this page comes from
- nixpkgs unstable: fdtools 2024.12.07
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms