Find the answer to your Linux question:
Results 1 to 10 of 10
Anyone know of a way to tail -f dmesg?...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Linux User
    Join Date
    Nov 2003
    Location
    Brooklyn, NY
    Posts
    347

    Tail Dmesg


    Anyone know of a way to tail -f dmesg?

  2. #2
    Linux Guru anomie's Avatar
    Join Date
    Mar 2005
    Location
    Texas
    Posts
    1,692
    Are you asking what the file name is of the ring buffer? The only time that I know of that it gets written to is during boot time. (But I could be mistaken.) What would be the purpose of putting tail -f on it? Just curious.

  3. #3
    Linux User
    Join Date
    Nov 2003
    Location
    Brooklyn, NY
    Posts
    347
    Quote Originally Posted by anomie
    Are you asking what the file name is of the ring buffer? The only time that I know of that it gets written to is during boot time. (But I could be mistaken.) What would be the purpose of putting tail -f on it? Just curious.
    tail -f <logfile>
    Would display the last few lines of the logfile as it keeps getting updated without having to run tail or cat again. Try it.

    I am trying to have dmesg displayed in the terminal and keep getting updated without me having to do anything.

  4. #4
    Linux Guru bigtomrodney's Avatar
    Join Date
    Nov 2004
    Location
    Ireland
    Posts
    6,132
    Try
    Code:
    dmesg | tail
    for static, I haven't got tailf here at the moment so I can't check - but you could always script something like
    Code:
    #!/bin/bash
    while true
    do dmesg | tail 
    sleep 3
    done
    That's just off the top of my head, you may tweak away. I'll let youhave that under the GPL !! haha

  5. #5
    Linux User
    Join Date
    Nov 2003
    Location
    Brooklyn, NY
    Posts
    347
    Quote Originally Posted by bigtomrodney
    Try
    Code:
    dmesg | tail
    for static, I haven't got tailf here at the moment so I can't check - but you could always script something like
    Code:
    #!/bin/bash
    while true
    do dmesg | tail 
    sleep 3
    done
    That's just off the top of my head, you may tweak away. I'll let youhave that under the GPL !! haha
    Yeah, I have tried
    Code:
    dmesg | tail
    but it does not want to accept -f.

  6. #6
    Linux Guru anomie's Avatar
    Join Date
    Mar 2005
    Location
    Texas
    Posts
    1,692
    tail -f <logfile>
    Would display the last few lines of the logfile as it keeps getting updated without having to run tail or cat again. Try it.
    I know that, but I am asking what the purpose is of tail -f on the ring buffer. It only gets written to during boot time (I think). So you can tail -f on it but nothing will happen.

  7. #7
    Linux Guru anomie's Avatar
    Join Date
    Mar 2005
    Location
    Texas
    Posts
    1,692
    The ring buffer in FC should be /var/log/dmesg. Not sure what it is in other distros.

    You have to tail that, not the dmesg command. (And as I said, I don't think you will be seeing anything change with it unless you are booting.)

  8. #8
    Linux Guru anomie's Avatar
    Join Date
    Mar 2005
    Location
    Texas
    Posts
    1,692
    It's interesting - under SuSE the ring buffer appears to be made up of two files.
    • /var/log/messages
    • /var/log/warn


    However, it is not all the lines in those files; it is only the kernel messages. So when dmesg gives results under SuSE it appears to contain those found in the two files with the prefix 'kernel:'.

    Your distro may be totally different.

  9. #9
    Linux Guru bigtomrodney's Avatar
    Join Date
    Nov 2004
    Location
    Ireland
    Posts
    6,132
    dmesg also reports any devices plugged in or out, as mentioned it is kernel messages. trying plugging in a flash drive, and run it before and after.

  10. #10
    Just Joined!
    Join Date
    Sep 2009
    Posts
    1

    This is how I do it...

    Code:
    while true;do sudo dmesg -c;done
    Keep in mind that the '-c' flag clears the message buffer into stdout. The 'sudo' is unnecessary if you are root. If you feel this is eating too much of your CPU resource, try adding a 'sleep 1' before the loop is done.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •