Some distros allow you to
tail -f /var/log/dmesghowever this file stops being written in Ubuntu after boot, so that's not so useful.
I then found the watch command, which executes a command every 2 seconds (configurable if you like). Just watching dmesg fills my terminal output from the start, which is less than useful, so I use tail to shrink it down a bit. The command:
watch "dmesg | tail -20"does exactly what I was after.
8 comments:
I think you can create following script
#!/bin/bash
while [ 1 ]; do
dmesg -c
done
And run with
./dmesg_mon >> dmesg_log
Then the dmesg will be log into file instead of console ;)
Cheers,
-Hieu
If you want to watch your kernel messages (dmesg) than tail -f kern.log
Now you can tail and log all at the same time ( this is on Ubuntu which is what you said you were using)
Thanks J!
This is perfect:
watch "dmesg | tail -20"
Super useful. Thanks!
Hi
I needed a complete dmesg log but avoid to delete it with dmesg -c and ended up with the "one-liner"
export F=/tmp/dmesg.log ; \
rm -f $F ; \
while true; do \
dmesg|comm -1 -3 --nocheck-order $F - | tee -a $F ; \
done
use "dmesg -wH" - it will print out the last messages in the dmesg ring buffer in real time
Nice tip! "dmesg -wH" does require kernel 3.5 or later and a new util-linux version. This blog post was written long before either of those existed. Even current Ubuntu LTS's util-linux is not new enough for it.
Another simple way:
Using 'Ctrl + Alt + Fn' to switch virtual console.
Post a Comment