我的服务器似乎一直在重启。我想知道为什么。
我怎么知道上次重新启动服务器的时间以及为什么?
root pts/0 139.193.156.125 Thu Aug 8 21:10 still logged in
reboot system boot 2.6.32-358.11.1. Thu Aug 8 20:38 - 21:11 (00:33)
reboot system boot 2.6.32-358.11.1. Thu Aug 8 20:15 - 21:11 (00:56)
reboot system boot 2.6.32-358.11.1. Thu Aug 8 19:16 - 21:11 (01:55)
reboot system boot 2.6.32-358.11.1. Thu Aug 8 18:56 - 21:11 (02:14)
reboot system boot 2.6.32-358.11.1. Thu Aug 8 18:24 - 21:11 (02:47)
root pts/1 139.193.156.125 Thu Aug 8 18:16 - crash (00:07)
root pts/0 195.254.135.181 Thu Aug 8 18:10 - crash (00:13)
reboot system boot 2.6.32-358.11.1. Thu Aug 8 17:52 - 21:11 (03:19)
root pts/0 195.254.135.181 Thu Aug 8 17:38 - crash (00:13)
reboot system boot 2.6.32-358.11.1. Thu Aug 8 17:08 - 21:11 (04:02)
reboot system boot 2.6.32-358.11.1. Thu Aug 8 16:58 - 21:11 (04:12)
reboot system boot 2.6.32-358.11.1. Thu Aug 8 16:45 - 21:11 (04:26)
reboot system boot 2.6.32-358.11.1. Thu Aug 8 16:35 - 21:11 (04:36)
reboot system boot 2.6.32-358.11.1. Thu Aug 8 16:27 - 21:11 (04:44)
reboot system boot 2.6.32-358.11.1. Thu Aug 8 15:59 - 21:11 (05:12)
reboot system boot 2.6.32-358.11.1. Thu Aug 8 06:15 - 21:11 (14:56)
root pts/1 208.74.121.102 Wed Aug 7 06:03 - 06:04 (00:00)
root pts/1 208.74.121.102 Tue Aug 6 15:34 - 17:40 (02:05)
root pts/0 139.193.156.125 Tue Aug 6 11:28 - 04:40 (1+17:11)
Run Code Online (Sandbox Code Playgroud)
在 Linux 中,有什么方法可以知道系统重新启动的原因吗?具体是高负载导致的吗?如果不是那么什么?
slm*_*slm 12
您可以使用以下 2 个命令 ( who
& last
) 找出系统上次重新启动的时间以及有关先前关闭或运行级别更改的消息。
为此,您可以使用该who
命令。具体用-b
开关。
$ who -b
system boot 2013-08-01 17:56
Run Code Online (Sandbox Code Playgroud)
这表示系统上次启动是 2013-08-01。
如果您有兴趣查看更广泛的先前重新启动列表,可以使用该last
命令。
$ last reboot | less
reboot system boot 2.6.35.14-106.fc Thu Aug 1 17:56 - 02:03 (7+08:06)
reboot system boot 2.6.35.14-106.fc Thu Aug 1 09:41 - 17:55 (08:14)
reboot system boot 2.6.35.14-106.fc Thu Jul 25 15:24 - 17:55 (7+02:31)
reboot system boot 2.6.35.14-106.fc Thu Jul 18 18:05 - 15:23 (6+21:17)
...
Run Code Online (Sandbox Code Playgroud)
您也可以last
为此使用该命令。你需要使用-x
开关。
$ last -x | less
saml pts/7 :pts/6:S.0 Sat Aug 3 21:30 - 21:30 (00:00)
saml pts/6 :0.0 Sat Aug 3 21:29 - 21:30 (00:01)
saml pts/4 :0.0 Fri Aug 2 21:49 - 22:16 (2+00:26)
saml pts/2 :0.0 Fri Aug 2 13:30 - 22:16 (2+08:45)
saml pts/1 :0.0 Fri Aug 2 13:05 still logged in
saml pts/0 :0.0 Fri Aug 2 12:37 still logged in
saml pts/0 :0.0 Fri Aug 2 12:35 - 12:37 (00:02)
saml pts/0 :0.0 Thu Aug 1 17:58 - 12:35 (18:36)
saml tty1 :0 Thu Aug 1 17:56 still logged in
runlevel (to lvl 5) 2.6.35.14-106.fc Thu Aug 1 17:56 - 02:04 (7+08:08)
reboot system boot 2.6.35.14-106.fc Thu Aug 1 17:56 - 02:04 (7+08:08)
shutdown system down 2.6.35.14-106.fc Thu Aug 1 17:55 - 17:56 (00:00)
runlevel (to lvl 6) 2.6.35.14-106.fc Thu Aug 1 17:55 - 17:55 (00:00)
saml tty2 Thu Aug 1 17:54 - down (00:01)
root tty2 Thu Aug 1 17:53 - 17:54 (00:00)
...
Run Code Online (Sandbox Code Playgroud)
/var/log/messages
Run Code Online (Sandbox Code Playgroud)
这是您应该检查与此相关的消息的主要日志文件。另外/var/log/syslog
(Ubuntu) 或/var/log/secure
(CentOS)
要找出您的服务器上次重新启动的时间,只需键入uptime
以查看它已启动多长时间。