要查询 Linux reboot 纪录的日期及时间,可以用 last 或 who 指令实现, 以下是使用方法:
who 指令
who 指令可以显示正在登入的使用者,除了登入的使用者外,也会显示上一次系统开机的时间,这包括开机及重新开机,例如:
$ who
samtang pts/0 2017-03-19 21:59 (x.x.x.x)
samtang pts/0 2017-03-19 21:59 (x.x.x.x)
上面的 2017-03-19 21:59 就是对上一次系统启动的时间。
last 指令
last 指令可以列出登入使用者及时间,只要查询 reboot 帐号便可以看到 reboot 时间,例如:
$ last reboot
reboot system boot 3.10.0-514.10.2. Mon Mar 6 11:18 – 22:05 (13+10:46)
reboot system boot 3.10.0-514.6.2.e Fri Feb 24 08:28 – 11:18 (10+02:50)
reboot system boot 3.10.0-514.el7.x Mon Jan 16 12:28 – 08:28 (38+19:59)
reboot system boot 3.10.0-514.el7.x Mon Jan 16 12:23 – 08:28 (38+20:04
reboot system boot 3.10.0-514.10.2. Mon Mar 6 11:18 – 22:05 (13+10:46)
reboot system boot 3.10.0-514.6.2.e Fri Feb 24 08:28 – 11:18 (10+02:50)
reboot system boot 3.10.0-514.el7.x Mon Jan 16 12:28 – 08:28 (38+19:59)
reboot system boot 3.10.0-514.el7.x Mon Jan 16 12:23 – 08:28 (38+20:04
除了看到 reboot 的时间外,也可以看到 reboot 时的 Kernel 版本,如果说 Kernel 版本变更了,大概知道是因为更新 Kernel 而需要 reboot 系统。