Dr. Xiao-Le Deng

Linux查看运行时间和最后重启时间

2020-09-22 16:00
#Skills #Linux

1、uptime:显示系统运行时间和系统最后重启时间

$ uptime
15:53:21 up 1 day,  6:07,  1 user,  load average: 0.93, 0.68, 0.50

$ uptime -s
2020-09-21 09:45:24

2、w:已登录账号和在干什么

$ w
15:54:06 up 1 day,  6:08,  1 user,  load average: 0.72, 0.66, 0.50
USER     TTY      FROM             LOGIN@   IDLE   JCPU   PCPU WHAT
shalom   :0       :0               Mon12   ?xdm?   4:16m  0.01s /usr/lib/gdm3/gdm-x-session

3、who -a:查看系统上传重启时间、LOGIN进程运行的信息、运行级别已经用户信息

$ who -a
           system boot  2020-09-21 09:45
shalom   ? :0           2020-09-21 12:19   ?          9511 (:0)
           run-level 5  2020-09-21 09:46

who -b 可以查到最后重启的时间

$ who -b
         system boot  2020-09-21 09:45

4、last:显示最近几次的重启时间已经运行时长

$ last
shalom   :0           :0               Mon Sep 21 12:19   still logged in
shalom   :0           :0               Mon Sep 21 09:46 - 12:19  (02:33)
reboot   system boot  5.4.0-47-generic Mon Sep 21 09:45   still running
shalom   :0           :0               Sun Sep 20 16:56 - down   (16:48)
reboot   system boot  5.4.0-47-generic Sun Sep 20 16:56 - 09:45  (16:48)
shalom   :0           :0               Sun Sep 20 16:05 - down   (00:50)
reboot   system boot  5.4.0-47-generic Sun Sep 20 16:05 - 16:55  (00:50)
shalom   :0           :0               Sun Sep 20 14:47 - down   (01:17)
reboot   system boot  5.4.0-47-generic Sun Sep 20 14:47 - 16:05  (01:17)
shalom   :0           :0               Sun Sep 20 14:33 - down   (00:13)
reboot   system boot  5.4.0-47-generic Sun Sep 20 14:33 - 14:47  (00:13)
shalom   :0           :0               Sun Sep 20 14:29 - crash  (00:03)
reboot   system boot  5.4.0-47-generic Sun Sep 20 14:29 - 14:47  (00:17)
shalom   :0           :0               Fri Sep 18 09:04 - down  (2+05:24)
reboot   system boot  5.4.0-47-generic Fri Sep 18 09:03 - 14:29 (2+05:25)
shalom   :0           :0               Thu Sep 17 16:34 - crash  (16:29)
shalom   :0           :0               Thu Sep 17 16:06 - 16:33  (00:27)
shalom   tty6                          Thu Sep 17 16:04 - crash  (16:59)
shalom   :0           :0               Thu Sep 17 13:31 - 16:06  (02:34)
reboot   system boot  5.4.0-47-generic Thu Sep 17 13:30 - 14:29 (3+00:58)

wtmp begins Thu Sep 17 13:30:44 2020

5、last reboot:查看最近几次重启的时间信息

$ last reboot
reboot   system boot  5.4.0-47-generic Mon Sep 21 09:45   still running
reboot   system boot  5.4.0-47-generic Sun Sep 20 16:56 - 09:45  (16:48)
reboot   system boot  5.4.0-47-generic Sun Sep 20 16:05 - 16:55  (00:50)
reboot   system boot  5.4.0-47-generic Sun Sep 20 14:47 - 16:05  (01:17)
reboot   system boot  5.4.0-47-generic Sun Sep 20 14:33 - 14:47  (00:13)
reboot   system boot  5.4.0-47-generic Sun Sep 20 14:29 - 14:47  (00:17)
reboot   system boot  5.4.0-47-generic Fri Sep 18 09:03 - 14:29 (2+05:25)
reboot   system boot  5.4.0-47-generic Thu Sep 17 13:30 - 14:29 (3+00:58)

wtmp begins Thu Sep 17 13:30:44 2020

参考