1、who 命令查看
who -b 查看最后一次系统启动的时间
who -r 查看当前系统运行时间
[root@test ~]# who -b
system boot 2017-02-04 10:09
[root@test ~]# who -r
run-level 5 2017-02-04 10:09
2、查看系统运行了多长时间
[root@test ~]# top
top - 10:46:41 up 37 min, 2 users, load average: 0.00, 0.00, 0.00
Tasks: 151 total, 1 running, 150 sleeping, 0 stopped, 0 zombie
Cpu(s): 0.0%us, 0.0%sy, 0.0%ni,100.0%id, 0.0%wa, 0.0%hi, 0.0%si, 0.0%st
Mem: 4151492k total, 199068k used, 3952424k free, 19044k buffers
Swap: 4161528k total, 0k used, 4161528k free, 91036k cached
[root@test ~]# w
10:49:57 up 40 min, 2 users, load average: 0.00, 0.00, 0.00
USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT
root pts/0 192.168.52.1 10:35 11:03 0.03s 0.00s man who
root pts/1 192.168.52.1 10:39 0.00s 0.02s 0.00s w
[root@test ~]# uptime
10:50:50 up 41 min, 2 users, load average: 0.00, 0.00, 0.00
3、查看linux系统关机的时间
last -x |grep shutdown
last -x |grep shutdown |head -1
[root@test ~]# last -x |grep shutdown
shutdown system down 2.6.32-431.el6.i Wed Jan 4 16:34 - 10:09 (30+17:34)
shutdown system down 2.6.32-431.el6.i Tue Jan 3 16:24 - 16:23 (23:59)
shutdown system down 2.6.32-431.el6.i Wed Dec 21 16:02 - 15:20 (12+23:17)
shutdown system down 2.6.32-431.el6.i Mon Nov 28 22:28 - 14:14 (22+15:46)
shutdown system down 2.6.32-431.el6.i Tue Nov 29 06:00 - 06:01 (00:00)
shutdown system down 2.6.32-431.el6.i Tue Nov 29 05:43 - 05:43 (00:00)
[root@test ~]# last -x |grep shutdown |head -1
shutdown system down 2.6.32-431.el6.i Wed Jan 4 16:34 - 10:09 (30+17:34)