查看linux系统的开机时间/重启历史记录

时间:2021-08-31 17:14:35

查看linux系统的开机时间/重启历史记录
1、who -b命令
[root@rusky opt]# who -b ---查看最后一次(上次)系统启动的时间
system boot Dec 27 05:06

2、who -r命令
[root@rusky opt]# who -r ---查看最后一次(上次)系统启动的时间,及运行级别
run-level 5 Dec 27 05:06

3、last reboot命令

[root@rusky opt]# last reboot
reboot system boot 2.6.32-358.el6.x Sat Dec 27 05:06 - 16:07 (4+11:00) 
reboot system boot 2.6.32-358.el6.x Wed Nov 5 20:00 - 16:07 (55+20:06) 
reboot system boot 2.6.32-358.el6.x Mon Oct 13 14:00 - 19:15 (23+05:15) 
reboot system boot 2.6.32-358.el6.x Sat Oct 11 09:14 - 13:59 (2+04:44) 
reboot system boot 2.6.32-358.el6.x Thu Oct 9 05:40 - 09:13 (2+03:32) 
reboot system boot 2.6.32-358.el6.x Wed Oct 8 21:48 - 05:40 (07:51) 
reboot system boot 2.6.32-358.el6.x Wed Oct 8 20:08 - 21:48 (01:39) 
reboot system boot 2.6.32-358.el6.x Wed Oct 8 16:29 - 20:08 (03:38) 
reboot system boot 2.6.32-358.el6.x Wed Oct 8 16:24 - 16:27 (00:02) 
reboot system boot 2.6.32-358.el6.x Mon Sep 29 18:59 - 16:23 (8+21:24) 
reboot system boot 2.6.32-358.el6.x Sun Sep 28 22:02 - 18:58 (20:56) 
reboot system boot 2.6.32-358.el6.x Sun Sep 28 20:18 - 22:01 (01:42) 
reboot system boot 2.6.32-358.el6.x Sun Sep 28 20:14 - 20:17 (00:02) 
reboot system boot 2.6.32-358.el6.x Sun Sep 28 20:12 - 20:17 (00:04)

wtmp begins Sun Sep 28 20:12:54 2014

5、top命令
up后表示系统到目前运行了多久时间。反过来推算系统重启时间
[root@rusky opt]# top

top - 16:10:12 up 4 days, 11:05, 4 users, load average: 0.00, 0.00, 0.00
Tasks: 421 total, 1 running, 420 sleeping, 0 stopped, 0 zombie
……

6、w命令
up后表示系统到目前运行了多久时间。反过来推算系统重启时间
[root@rusky opt]# w
16:47:16 up 4 days, 11:42, 3 users, load average: 0.00, 0.00, 0.00

7、uptime命令及查看/proc/uptime

[root@rusky  opt]# uptime
16:47:53 up 4 days, 11:42, 3 users, load average: 0.00, 0.00, 0.00

[root@rusky opt]# date -d "`cut -f1 -d. /proc/uptime` seconds ago" --查看最近一次系统重启的时间
Sat Dec 27 05:05:12 CST 2014

[root@rusky opt]# date -d "$(awk -F. '{print $1}' /proc/uptime) second ago" +"%Y-%m-%d %H:%M:%S" 
2014-12-27 05:05:12