很多时候,工作需要,需要知道Linux系统运行了多久时间,上次开机启动时间;
1: who 命令查看
who -b 查看最后一次系统启动的时间。
who -r 查看当前系统运行时间
who -b
[istester@iZ94b31ttqsZ istester.com]$ who -b
system boot 2019-03-31 11:32
或者,who -r
[istester@iZ94b31ttqsZ istester.com]$ who -r
run-level 3 2019-03-31 11:32
2: last reboot
如下所示last reboot可以看到Linux系统历史启动的时间。 重启一下操作系统后,然后
[istester@iZ94b31ttqsZ istester.com]$ last reboot
reboot system boot 2.6.32-431.23.3. Sun Mar 31 11:32 - 09:58 (81+22:25)
reboot system boot 2.6.32-431.23.3. Sun Mar 31 11:05 - 11:31 (00:26)
reboot system boot 2.6.32-431.23.3. Wed Nov 29 00:08 - 10:47 (487+10:39)
reboot system boot 2.6.32-431.23.3. Sun Sep 27 15:56 - 00:07 (793+08:10)
reboot system boot 2.6.32-431.23.3. Wed Jun 24 18:22 - 00:28 (94+06:06)
reboot system boot 2.6.32-431.23.3. Wed Jun 24 18:13 - 18:21 (00:08)
reboot system boot 2.6.32-431.23.3. Wed Jun 24 17:50 - 18:13 (00:22)
reboot system boot 2.6.32-431.23.3. Tue Jun 23 18:17 - 17:50 (23:32)
reboot system boot 2.6.32-431.23.3. Wed Mar 4 10:47 - 18:15 (111+07:28)
reboot system boot 2.6.32-431.23.3. Wed Mar 4 10:41 - 10:46 (00:05)
reboot system boot 2.6.32-431.23.3. Wed Dec 31 10:53 - 10:46 (62+23:53)
如果只需要查看最后一次Linux系统启动的时间
[istester@iZ94b31ttqsZ istester.com]$ last reboot | head -1
reboot system boot 2.6.32-431.23.3. Sun Mar 31 11:32 - 09:58 (81+22:26)
3:TOP命令查看
如下截图所示,up后表示系统到目前运行了多久时间。反过来推算系统重启时间
4: w命令查看
如下截图所示,up后表示系统到目前运行了多久时间。反过来推算系统重启时间
[istester@iZ94b31ttqsZ istester.com]$ w
10:01:00 up 81 days, 22:28, 2 users, load average: 0.00, 0.00, 0.00
USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT
root pts/0 183.14.133.208 09:50 8:37 0.00s 0.00s -zsh
root pts/1 183.14.133.208 09:55 0.00s 0.02s 0.00s w
5:uptime 命令查看
[istester@iZ94b31ttqsZ istester.com]$ uptime
10:01:37 up 81 days, 22:29, 2 users, load average: 0.00, 0.00, 0.00