cancel
Showing results for 
Search instead for 
Did you mean: 

dmesg timestamp; msgbuf

 
Highlighted
Occasional Contributor

dmesg timestamp; msgbuf

Hello, 

1. Is msgbuf file content is identical to the output of dmesg ?

2. how can I add timestamp to dmesgbuf ?

3. how /var/adm/msgbuf is created? I have this file in one server but missing on ther other 

 

 

3 REPLIES 3
Highlighted
Honored Contributor

Re: dmesg timestamp; msgbuf

dmesg is an in-core buffer kept by the kernel and also a command which will always report everything when you run it *UNLESS* you use the - option (I know, it's hard to see). This option is designed to keep a cumulative log and an example using cron is available in /usr/newconfig, but it looks like this:

00,10,20,30,40,50 * * * * /usr/sbin/dmesg - >> /var/adm/messages


Be sure you use the - flag. This makes dmesg scan the buffer for new info and if none is found, nothing is reported.  Otherwise a timestamp is added to the file and the newest contents from dmesg is added.

Actually, I prefer /var/adm/dmesg.log rather than "messages" since it makes more sense.
Like this:

00,10,20,30,40,50 * * * * /usr/sbin/dmesg - >> /var/adm/dmesg.log

The msgbuf is a scratch file used by the "-" option and should not be touched.



Bill Hassell, sysadmin
Highlighted
Occasional Contributor

Re: dmesg timestamp; msgbuf

Bill, thank you so much for your response. 

Is msgbuf file is created by the system itself? Because I did not have msgbuf file until I ran dmesg command. 

 

 

Highlighted
Honored Contributor

Re: dmesg timestamp; msgbuf

As I mentioned, msgbuf is a temp file used by the dmesg tool. Don't use it for information. Use dmesg for latest info and append additional info using the above cron example.


Bill Hassell, sysadmin