dmesg日志时间转换脚本
1、shell脚本
#!/bin/bash if [ $# -ne 1 ];then echo "input an dmesg time" exit 1 fi unix_time=`echo "$(date +%s) - $(cat /proc/uptime | cut -f 1 -d' ') + ${1}" | bc` stamp=`echo "scale=0; ${unix_time} / 1" | bc` echo ${stamp} date -d @${stamp} "+%Y-%m-%d %H:%M:%S"
2、命令直接转换
dmesg_from_boot_seconds=97870.113560 && date -d "@$(echo "$(date +%s) - $(cat /proc/uptime | cut -f 1 -d' ') + ${dmesg_from_boot_seconds}" | bc )" '+%Y-%m-%d %H:%M:%S.%N'

浙公网安备 33010602011771号