Closed 12D687 closed 1 year ago
Instead of using the dmesg
command, you can use one of the underlying kernel interfaces, which are:
/dev/kmsg
. If you do a SEEK_END
on it, you'll only be reading newly appearing messages. Such reads don't affect other readers from that pseudo-file./proc/kmsg
. Reads do affect other readers (whatever has been read disappears for all readers).syslog(2)
.I recommend the first option.
Does this address your question/need?
Also, how custom does your log file need to be? Most distros either readily direct kernel messages to a separate log file or use systemd journal, in which case journalctl -k
(you can also add -f
) will show you kernel messages only.
So you can do e.g.:
journalctl -kf --lines=0 | fgrep --line-buffered ' kernel: LKRG: ' > new-lkrg-messages
Not an issue we need to track, so I'm closing, but please feel free to add further comments anyway.
I wonder If there is any possibility to pipe the lkrg output for custom logfile. Because it's cumbersome and unreliable for reading kernel buffer using dmesg.