Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question

migrated from Aug 26 '11 at 15:24

This question came from our site for professional and enthusiast programmers.

Of course, I can always write a user space program, and read the value from some shared memory or /proc file etc, but I am just asking this question out of curiosity. – Shahbaz Aug 26 '11 at 12:03
up vote 5 down vote accepted

Have you tried tail -F, eg.

tail -F /var/log/messages
share|improve this answer
Thanks that's what I wanted. I read the man page for tail but the part for -f was not at all understandable to me. – Shahbaz Aug 26 '11 at 12:08
@Shahbaz : Be careful if you are looking at a file that is log rotated, i.e. logs are automatically archived, like syslog.0, syslog.1.gz etc.. As soon as the file you watching is rotated, you won't see any new lines. You have to restart tail -f. (At least this is the case on my system) – Xavier T. Aug 26 '11 at 12:33
@Xavier T. Thanks. I was just doing this for a small test however to see if my driver worked – Shahbaz Aug 26 '11 at 14:09
You can of course use the tail -F command which watches for changed/rotated files and continues to watch the file with the given name. – ar. Aug 26 '11 at 14:38

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
share|improve this answer

You could use

 cat /proc/kmsg

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

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.