How to view linux kernel logs live?

I have a kernel module logging input of some sensor while I work with it. I want to see if there is a command that outputs /var/log/messages (for example) but waits for more logs to come. That is, some program like dmesg except that it stays on and keeps printing newly-come logs.


Solution 1:

Have you tried tail -F, eg.

tail -F /var/log/messages

Solution 2:

You can:

  • execute dmesg every second: while true; do dmesg -c; sleep 1; done
  • print everything appended to /var/log/messages: tail -f /var/log/messages
  • dump the logs on the serial port and read them on another PC. You will need to add to your kernel boot parameters: console=ttyS0,115200 console=tty0 ignore_loglevel and remove quiet

Solution 3:

You could use

 cat /proc/kmsg

By this way you could get all kernel messages when they come