Pages - Menu

Monday, May 25, 2009

how to monitor dmesg in real time

I was looking around for a way of monitoring dmesg output in realtime.

Some distros allow you to
tail -f /var/log/dmesg
however 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.