复制代码代码如下: [sql] # shutdown -h now] Broadcast message from root (tty1) (Thu May 3 10:58:22 2012): The system is going down for system halt NOW! INIT: Switching to runlevel: 0 INIT: Sending processes the TERM signal 执行shutdown –r now后发送重启消息:
复制代码代码如下: [sql] # shutdown -r now Broadcast message from root (tty1) (Thu May 3 11:18:22 2012): The system is going down for system reboot NOW! INIT: Switching to runlevel: 6 INIT: Sending processes the TERM signal 执行shutdown后,其他用户不能再登入系统,另我们可以指定系统挂起或重启的时间以及说明,如下两例: 凌晨1::00停机维护:
复制代码代码如下: [sql] shutdown –h 1:00 "going down for scheduled maintenance. Expected downtime is 1 hour." 指定相对关机时间15分钟后关机:
复制代码代码如下: [sql] shutdown –h +15 "going down for emergency check." halt和reboot命令 halt记录关机情况,终止非必要进程,执行sync系统调用,等待文件系统写操作完成,然后停止内核,poweroff命令等价于halt. 从以上"shutdown –h"和"shutdown –r"执行输出可知,执行halt即进入运行级别0,执行reboot即进入运行级别6,日志文件/var/log/messages中会记录相应日志。 系统重启日志:
复制代码代码如下: [sql] May 3 11:45:25 slot14 shutdown[11119]: shutting down for system reboot May 3 11:45:25 slot14 init: Switching to runlevel: 6 May 3 11:45:25 slot14 user_cmd: 2012-05-03 11:45:25 shutdown -r now by root from [root tty1 May 3 11:44] 系统挂起日志: 复制代码代码如下: [sql] May 3 10:50:22 slot14 shutdown[11561]: shutting down for system halt May 3 10:50:22 slot14 init: Switching to runlevel: 0 May 3 10:50:22 slot14 user_cmd: 2012-05-03 10:50:22 shutdown -h now by root from [root tty1 May 3 10:48] 通过查看/var/log/messages日志记录,可判断机器是无端重启还是人为地重启。 telinit命令 执行telinit命令可以指引init进入指定的运行级别,如重启系统: