centos查看启动时间

系统启动时间

who -b
         system boot  Dec 20 10:45

date -d "$(awk -F. '{print $1}' /proc/uptime) second ago" +"%Y-%m-%d %H:%M:%S"
2019-12-20 10:45:03

系统已运行时间

cat /proc/uptime| awk -F. '{run_days=$1 / 86400;run_hour=($1 % 86400)/3600;run_minute=($1 % 3600)/60;run_second=$1 % 60;printf("%dd %d:%d:%d\n",run_days,run_hour,run_minute,run_second)}'
 

1d 3:35:33

 
 
 

系统启动时间

who -b
         system boot  Dec 20 10:45

date -d "$(awk -F. '{print $1}' /proc/uptime) second ago" +"%Y-%m-%d %H:%M:%S"
2019-12-20 10:45:03

系统已运行时间

cat /proc/uptime| awk -F. '{run_days=$1 / 86400;run_hour=($1 % 86400)/3600;run_minute=($1 % 3600)/60;run_second=$1 % 60;printf("%dd %d:%d:%d\n",run_days,run_hour,run_minute,run_second)}'
 

1d 3:35:33

 

猜你喜欢

转载自www.cnblogs.com/rocazj/p/12076842.html