#!/usr/bin/perl
use strict;
use warnings;
my @dmesg_new = ();
my $dmesg = "/bin/dmesg";
my @dmesg_old = `$dmesg`;
my $now = time();
my $uptime = `cat /proc/uptime | cut -d"." -f1`;
my $t_now = $now - $uptime;
sub format_time {
my @time = localtime $_[0];
$time[4]+=1; # Adjust Month
$time[5]+=1900; # Adjust Year
return sprintf '%4i-%02i-%02i %02i:%02i:%02i', @time[reverse 0..5];
}
foreach my $line ( @dmesg_old )
{
chomp( $line );
if( $line =~ m/\[\s*(\d+)\.(\d+)\](.*)/i )
{
# now - uptime + sekunden
my $t_time = format_time( $t_now + $1 );
push( @dmesg_new , "[$t_time] $3" );
}
}
print join( "\n", @dmesg_new );
print "\n";
脚本下载地址:dmesg.tar
使用perl脚本输出可读的dmesg时间 by 桔子小窝 is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.
高端!果断看不懂 😎
V友路过 zjgood。明明Azure比Loc快,为毛还要用loc呢~
@郑杰 : 可能是因为我之前在HK数据中心还不是很给力的时候一直用的Azure然后受不了了。。。然后就换成Loc了。。。