0

On VMWare or on bare metal, Linux display by default live dmesg content directly to stdout.

ifup/ifdown

But when I'm connected through SSH, it doesn't show up even to the command succeeds

How do I forward every dmesg log through SSH ?

dmesg -wH, watch or tail are not what i'm looking for. I don't want to see the whole dmesg, only the live ones and without disrupting my shell.

Tangogow
  • 23
  • 4
  • `/dev/tty1` is configured to be the **console**, and system messages are written to the console; that's why you see your "dmesg" messages when login in "locally" – Fravadona Jan 17 '23 at 16:03
  • You can always use `dmesg -W &` to run it *in background* (it's output will go to the terminal; to stop it run `fg` to get it to foreground and press `Ctrl-C` as usual, or kill the process). – mjf Jan 18 '23 at 07:30

2 Answers2

0

Thanks @mjf, you were close.

dmesg -W & doesn't seems to be working since -W uppercase doesn't exist, but dmesg -w & with -w lowercase works perfectly.

Tangogow
  • 23
  • 4
  • Well, @Tangogov, on all my systems the `-W` option exists and is described in the manual page as `-W, --follow-new Wait and print only new messages.` There is also the mentioned `-w` with this description in the manual: `-w, --follow Wait for new messages. This feature is supported only on systems with a readable /dev/kmsg (since kernel 3.5.0).` Also, the `-w` first prints the circular buffer and then waits for new messages to arrive, the `-W` just waits for new messages to arrive. Just to clarify... – mjf Mar 17 '23 at 12:00
0

To disable messages to console: echo 0 > /proc/sys/kernel/printk. To read messages at a remote machine: ssh yourname@frommachine "cat /dev/kmsg" and to get it into a file at the remote machine while watching: ssh yourname@frommachine "cat /dev/kmsg" | tee frommachinessyslog.log.