Dmesg with Date and Time

Dear All,

I am looking to enable Date and time in dmesg output for for centos 5.8.

Unfortunately the current version doesn't support -T option.

Also i am looking for solutions which can enable the date& time via kernal or updating the dmesg utility.

or maybe via single command line.

Best Regards
Pistachio

There is no kernel or command line option to turn on dmesg formatted date output in CentOS 5.8.

However you can easily write a script to produce a new file from the dmesg output that does contain a formatted date.

Here is a Perl script that I sometimes use:

#!/usr/bin/perl -wn

use strict;

foreach my $line (<>) {
    my ($uptime) = do { local @ARGV='/proc/uptime';<>}; ($uptime) = ($uptime =~ /^(\d+)\./);
    $line=~/^\[\s*(\d+)\.\d+\](.+)/;
    printf "[%s]%s\n", scalar localtime(time - $uptime + $1), $2;
}

I did not write this script. Just found it somewhere on the internet. Do an Internet search and you will find a lot of similar scripts.

Just pipe the output of dmesg to this script and you should get date formatted output

I tried to execute the same script in Centos 6.4. But I didn't get any output..

perl dmesg.pl

NO output triggered.