最近在排查一个core问题,对dmesg的时间戳,做了一个转化工具

#!/bin/bash

uptime_ts=`cat /proc/uptime | awk '{ print $1}'`
#echo $uptime_ts
dmesg | awk -v uptime_ts=$uptime_ts 'BEGIN {
        now_ts = systime();
        start_ts = now_ts - uptime_ts;
        #print "system start time seconds:", start_ts;
        #print "system start time:", strftime("[%Y/%m/%d %H:%M:%S]", start_ts);
}
{
        print strftime("[%Y/%m/%d %H:%M:%S]", start_ts + substr($1, 2, length($1) - 2)), $0
}'

你可能感兴趣的:(读书整理)