Thursday, October 17, 2013

Convert Dmesg timestamp to Human readable format.

I am using ubuntu 12.04 where util-linux package is update and you have the option of converting dmesg timestamp to human readable format just by passing option "-T". But for those who are using the dmesg which doesn't support "-T" option can use below simple program to convert it into human readable format.

Program_file: dmesg_realtime.sh
Parameters: dmesg_timestamp

#cat dmesg_realtime.sh
#!/bin/bash
ut=`cut -d' ' -f1 < /proc/uptime`
ts=`date +%s`
realtime_date=`date -d"70-1-1 + $ts sec - $ut sec + $1 sec" +"%F %T"`
echo $realtime_date

#./dmesg_realtime.sh 8642755.690405
2013-08-16 08:48:09