首页 > 系统服务 > 详细

【抄】Linux查看系统启动时间

时间:2020-11-16 22:38:11      阅读:35      评论:0      收藏:0      [点我收藏+]

  本篇简单介绍查看linux系统启动时间的方法介绍。

Last命令

$ last reboot
wtmp begins Mon Nov  2 06:35:26 2020

who命令

$ who -b
         system boot  2020-09-22 03:06

  可以发现,跟上面last命令的输出结果不一致,感觉应该以who -b为准。

TOP命令

  根据系统到目前运行了多久时间,反过来推算系统重启时间。

$ top
top - 12:19:28 up 55 days,  9:13,  2 users,  load average: 0.02, 0.03, 0.00
...

w命令

  根据系统到目前运行了多久时间,反过来推算系统重启时间。

$ w
 12:27:58 up 55 days,  9:21,  2 users,  load average: 0.00, 0.01, 0.00

uptime 命令

  根据系统到目前运行了多久时间,反过来推算系统重启时间。

$ uptime
 12:28:56 up 55 days,  9:22,  2 users,  load average: 0.00, 0.00, 0.00

查看/proc/uptime

$ date -d "`cut -f1 -d. /proc/uptime` seconds ago"
Tue Sep 22 03:06:10 UTC 2020

$ date -d "$(awk -F. ‘{print $1}‘ /proc/uptime) second ago" +"%Y-%m-%d %H:%M:%S" 
2020-09-22 03:06:10
$ uptime | > perl -ne /.*up +(?:(\d+) days?,? +)?(\d+):(\d+),.*/; $total=((($1*24+$2)*60+$3)*60);
> $now=time(); $now-=$total; $now=localtime($now); print $now,"\n";Tue Sep 22 03:06:25 2020

 

参考:

  https://www.cnblogs.com/kerrycode/p/3759395.html

  https://www.thegeekstuff.com/2011/10/linux-reboot-date-and-time

【抄】Linux查看系统启动时间

原文:https://www.cnblogs.com/Hi-blog/p/linux-reboot-date-and-time.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!