linux 查看系統(tǒng)開(kāi)機(jī)時(shí)間

2019-01-21 18:00 更新

有時(shí)候需要查看Linux系統(tǒng)運(yùn)行了多久時(shí)間,此時(shí)需要知道上次開(kāi)機(jī)啟動(dòng)時(shí)間; 有時(shí)候由于斷電或供電故障突然停機(jī),需要查看Linux開(kāi)機(jī)時(shí)間/重啟時(shí)間;  下面總結(jié)一些查看Linux開(kāi)機(jī)關(guān)機(jī)時(shí)間的方法(非常全面)

1: who 命令查看

      who -b 查看最后一次系統(tǒng)啟動(dòng)的時(shí)間。

      who -r 查看系統(tǒng)是以哪一級(jí)別啟動(dòng)的。

[root@DB-Server ~]# who -b

         system boot May 11 09:27



2: last  reboot

如下所示last reboot可以看到Linux系統(tǒng)歷史啟動(dòng)的時(shí)間。 重啟一下操作系統(tǒng)后,然后

[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系統(tǒng)啟動(dòng)的時(shí)間

[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后表示系統(tǒng)到目前運(yùn)行了多久時(shí)間。反過(guò)來(lái)推算系統(tǒng)重啟時(shí)間


4: w命令查看

如下截圖所示,up后表示系統(tǒng)到目前運(yùn)行了多久時(shí)間。反過(guò)來(lái)推算系統(tǒng)重啟時(shí)間


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


文章來(lái)自:https://www.cnblogs.com/kerrycode/p/3759395.html 修改了 who -r 說(shuō)明


以上內(nèi)容是否對(duì)您有幫助:
在線筆記
App下載
App下載

掃描二維碼

下載編程獅App

公眾號(hào)
微信公眾號(hào)

編程獅公眾號(hào)