I've been seeing a rather odd problem in 12.1-STABLE. I'm not sure if it was also in older releases. When I run the dmesg(8) command, I see records from several previous boots of the system. For example:
These also appear in /var/run/dmesg.boot:
Other uses may not see this, as non-kernel messages will displace older messages from the buffer. Note that this is 3 different kernel builds, yet they share the same dmesg(8) buffer for some reason. There is no mention in the manpage about the message buffer being preserved across reboots. Other than doing a
The reason that this is a problem is that I have some scripts that run at startup and shutdown that look for issues in the buffer, and if it finds an issue it emails a report to the system managers. But even if the issue is corrected, the managers are still notified because the messages from a previous boot are still present in the buffer.
Code:
(0:11) hostname:/sysprog/terry# dmesg | grep -E "BOOT|STABLE"
---<<BOOT>>---
FreeBSD 12.1-STABLE #0 r359769: Fri Apr 10 02:04:44 EDT 2020
---<<BOOT>>---
FreeBSD 12.1-STABLE #0 r360560: Fri May 1 21:53:51 EDT 2020
---<<BOOT>>---
FreeBSD 12.1-STABLE #0 r360668: Tue May 5 15:25:15 EDT 2020
Code:
(0:12) hostname:/sysprog/terry# grep -E "BOOT|STABLE" /var/run/dmesg.boot
---<<BOOT>>---
FreeBSD 12.1-STABLE #0 r359769: Fri Apr 10 02:04:44 EDT 2020
---<<BOOT>>---
FreeBSD 12.1-STABLE #0 r360560: Fri May 1 21:53:51 EDT 2020
---<<BOOT>>---
FreeBSD 12.1-STABLE #0 r360668: Tue May 5 15:25:15 EDT 2020
# dmesg -c
to clear the buffer before a reboot, is there any way to prevent this from happening?The reason that this is a problem is that I have some scripts that run at startup and shutdown that look for issues in the buffer, and if it finds an issue it emails a report to the system managers. But even if the issue is corrected, the managers are still notified because the messages from a previous boot are still present in the buffer.