Clearing dmesg logs

What is dmesg?

 

The main purpose of dmesg is to display kernel messages. dmesg can provide helpful information in case of hardware problems or problems with loading a module into the kernel. In addition, with dmesg, you can determine what hardware is installed on your server. During every boot, Linux checks your hardware and logs information about it. You can view these logs using the command /bin/dmesg.

 

Clearing the kernel ring buffer

 

If you want you can backup the logs using dmesg > filename before clearing it. Just execute the following command to clear and frest start the ring buffer loggin (make sure you have logged in as root).

 

  • # dmesg -c

 

Execute the command dmesg to make sure the logs are cleared. Check man dmesg for more help.

 

Clearing dmesg logs in FreeBSD

 

 

Ssh your server as root and try the following

 

  • # sysctl kern.msgbuf_clear=1 
    
  • kern.msgbuf_clear: 0 -> 0 
    
  • #