Linux下如何查看系统启动时间和运行时间
[ 1.uptime命令
输出:16:11:40 up 59 days, 4:21, 2 users, load average: 0.00, 0.01, 0.00
2.查看/proc/uptime文件计算系统启动时间
cat /proc/uptime
输出: 5113396.94 575949.85
第一数字即是系统已运行的时间5113396.94 秒,运用系统工具date即可算出系统启动时间
](http://www.cnblogs.com/kerrycode/p/3759395.html)
代码: 全选 date -d "$(awk -F. '{print $1}' /proc/uptime) second ago" +"%Y-%m-%d %H:%M:%S"
[
输出: 2008-11-09 11:50:31
3.查看/proc/uptime文件计算系统运行时间 ](http://www.cnblogs.com/kerrycode/p/3759395.html)
Linux查看系统开机时间
2014-05-29 16:21 by 潇湘隐者, 48349 阅读, 1 评论, 收藏 , 编辑
有时候需要查看Linux系统运行了多久时间,此时需要知道上次开机启动时间; 有时候由于断电或供电故障突然停机,需要查看Linux开机时间/重启时间; 下面总结一些查看Linux开机关机时间的方法(非常全面)
1: who 命令查看
who -b 查看最后一次系统启动的时间。
who -r 查看当前系统运行时间
[root@DB-Server ~]# who -b
system boot May 11 09:27
2: last reboot
如下所示last reboot可以看到Linux系统历史启动的时间。 重启一下操作系统后,然后
[root@DB-Server ~]# last reboot
reboot system boot 2.6.9-42.ELsmp Thu May 29 15:25 (00:07)
reboot system boot 2.6.9-42.ELsmp Sun May 11 09:27 (18+05:55)
wtmp begins Mon May 5 16:18:57 2014
如果只需要查看最后一次Linux系统启动的时间
[root@DB-Server ~]# last reboot | head -1
reboot system boot 2.6.9-42.ELsmp Thu May 29 15:25 (00:08)
3:TOP命令查看
如下截图所示,up后表示系统到目前运行了多久时间。反过来推算系统重启时间
4: w命令查看
如下截图所示,up后表示系统到目前运行了多久时间。反过来推算系统重启时间
[](http://images.cnitblog.com/blog/73542/201405/291621120091350.png)[](http://images.cnitblog.com/blog/73542/201405/291621129475962.png)
5:uptime 命令查看
6: 查看/proc/uptime
[root@DB-Server ~]# cat /proc/uptime
1415.59 1401.42
[root@DB-Server ~]# date -d "cut -f1 -d. /proc/uptime
seconds ago"
Thu May 29 15:24:57 CST 2014
[root@DB-Server ~]# date -d "$(awk -F. '{print $1}' /proc/uptime) second ago"
+"%Y-%m-%d %H:%M:%S"
2014-05-29 15:24:57
[](http://images.cnitblog.com/blog/73542/201405/291621193532872.png)[](http://images.cnitblog.com/blog/73542/201405/291621202283971.png)
参考资料:
http://www.thegeekstuff.com/2011/10/linux-reboot-date-and-time/
http://www.averainy.info/linux-system-operation-time-and-the-view-of-the- latest-powered-up-time/
About Me
.............................................................................................................................................
● 本文整理自网络
● 本文在itpub( http://blog.itpub.net/26736162/abstract/1/ )、博客园( http://www.cnblogs.com/lhrbest )和个人微信公众号( xiaomaimiaolhr )上有同步更新
● 本文itpub地址: http://blog.itpub.net/26736162/abstract/1/
● 本文博客园地址: http://www.cnblogs.com/lhrbest
● 本文pdf版、个人简介及小麦苗云盘地址: http://blog.itpub.net/26736162/viewspace-1624453/
● 数据库笔试面试题库及解答: http://blog.itpub.net/26736162/viewspace-2134706/
● DBA宝典今日头条号地址: http://www.toutiao.com/c/user/6401772890/#mid=1564638659405826
.............................................................................................................................................
● QQ群: 230161599 微信群:私聊
● 联系我请加QQ好友(646634621),注明添加缘由
● 于 2017-07-01 09:00 ~ 2017-07-31 22:00 在魔都完成
● 文章内容来源于小麦苗的学习笔记,部分整理自网络,若有侵权或不当之处还请谅解
● 版权所有,欢迎分享本文,转载请保留出处
.............................................................................................................................................
● 小麦苗的微店 : https://weidian.com/s/793741433?wfr=c&ifr=shopdetail
● 小麦苗出版的数据库类丛书 : http://blog.itpub.net/26736162/viewspace-2142121/
.............................................................................................................................................
使用 微信客户端 扫描下面的二维码来关注小麦苗的微信公众号( xiaomaimiaolhr )及QQ群(DBA宝典), 学习最实用的数据库技术。
![]()
![]()
小麦苗的微信公众号 小麦苗的QQ群 小麦苗的微店
.............................................................................................................................................
免责申明:文章和图片全部来源于公开网络,如有侵权,请通知删除 server@dude6.com