How to view linux kernel logs live?
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 removequiet
Related videos on Youtube
Shahbaz
Color discrimination is racism. Be it skin color or passport color. I am a generalist, currently working at Google on ANGLE. Previously, I was a graphics programmer at Eidos Montreal working on the Shadow of the Tomb Raider. Before that, I was a Roboticist working on embedded and realtime systems. I got my PhD working on robotic skins, both their firmware and their real-time driver/software. My bachelors has been in Software Engineering with a personal focus on algorithms. Feel free to check out my gitlab account for some goodies, like tutorials on Vulkan, data structures in C, C bindings for pandoc and more!
Updated on September 18, 2022Comments
-
Shahbaz over 1 year
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. -
Admin over 12 yearsThanks that's what I wanted. I read the man page for
tail
but the part for-f
was not at all understandable to me. -
Admin over 12 years@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) -
Admin over 12 years@Xavier T. Thanks. I was just doing this for a small test however to see if my driver worked
-
ar. over 12 yearsYou can of course use the
tail -F
command which watches for changed/rotated files and continues to watch the file with the given name.