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

来源:互联网 发布:协同过滤推荐php 编辑:程序博客网 时间:2024/05/16 00:32
#!/bin/sh  
  
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  
}'  
阅读全文
0 0
原创粉丝点击