Linux系统有7个运行级别(runlevel)
运行级别0:系统停机状态,系统默认运行级别不能设为0,否则不能正常启动
运行级别1:单用户工作状态,root权限,用于系统维护,禁止远程登陆
运行级别2:多用户状态(没有NFS)
运行级别3:完全的多用户状态(有NFS),登陆后进入控制台命令行模式
运行级别4:系统未使用,保留
运行级别5:X11控制台,登陆后进入图形GUI模式
运行级别6:系统正常关闭并重启,默认运行级别不能设为6,否则不能正常启动
last -x
runlevel (to lvl 3) 2.6.32-573.12.1. Sun Apr 9 17:34- 00:22 (1+06:48)
reboot systemboot 2.6.32-573.12.1. Sun Apr 9 17:34 - 00:22 (1+06:48)
shutdown system down 2.6.32-573.12.1. Sun Apr 9 17:30- 17:34 (00:03)
runlevel (to lvl 6) 2.6.32-573.12.1. Sun Apr 9 17:30- 17:30 (00:00)
runlevel (to lvl 3) 2.6.32-573.12.1. Sun Apr 9 17:18- 17:30 (00:12)
reboot systemboot 2.6.32-573.12.1. Sun Apr 9 17:18 - 17:30 (00:12)
shutdown system down 2.6.32-573.12.1. Sun Apr 9 17:15- 17:18 (00:03)
runlevel (to lvl 6) 2.6.32-573.12.1. Sun Apr 9 17:14- 17:15 (00:00)
runlevel (to lvl 3) 2.6.32-573.12.1. Tue Apr 4 14:07- 00:22 (6+10:15)
reboot systemboot 2.6.32-573.12.1. Tue Apr 4 14:07 - 00:22 (6+10:15)
shutdown system down 2.6.32-573.12.1. Tue Apr 4 14:03- 14:07 (00:03)
runlevel (to lvl 6) 2.6.32-573.12.1. Tue Apr 4 14:03- 14:03 (00:00)
在centos 6里面,graceful shutdown是有从6到down 到boot再到3的过程的
You should see alternating runlevels 3 with either 0 or 6,such as
3->6->3->6->0->3->6. It doesn‘t have to be runlevel 3. For CM andMessaging,
it‘s runlevel 4. Check /etc/inittab to see the default. However, when you see
it alternate default runlevels with 0‘s or 6‘s where0=shutdown and 6=reboot,
this isgraceful. If you see 2 3‘s in a row, itwas ungraceful.
EX: runlevel (to lvl 3) 2.6.18-164.15.1. Thu Feb 10 10:31 - 08:11 (400+20:39)
EX: reboot system boot 2.6.18-164.15.1. Thu Feb 10 10:31 (400+20:39)
EX: shutdown systemdown 2.6.18-128.7.1.e Thu Feb 10 10:27 -08:11 (400+20:43)
EX: runlevel (to lvl6) 2.6.18-128.7.1.e Thu Feb 10 10:27 -10:27 (00:00)
If you see something like this where you go from runlevel 3to a system boot,
then you had anungraceful shutdown (3->3).
EX: runlevel (to lvl3) 2.6.18-164.15.1. Thu Feb 10 10:31 -08:11 (400+20:39)
EX: reboot system boot 2.6.18-164.15.1. Thu Feb 10 10:31 (400+20:39)
EX: runlevel (to lvl3) 2.6.18-128.7.1.e Thu Feb 10 10:27 -crash (00:00)
如果是从3 到3 就意味着,关机的时候,系统还没来得及识别到6,就已经断电了,就是Ungraceful shutdown。
[[email protected] ~]# last -x
root pts/0 192.168.17.1 Tue Apr 11 14:57 still loggedin
runlevel (to lvl 5) 2.6.32-642.el6.x Tue Apr 1114:57 - 14:58 (00:00)
reboot system boot 2.6.32-642.el6.x TueApr 11 14:57 - 14:58 (00:00)
lyp pts/0 192.168.17.1 Tue Apr 11 14:53 - crash (00:03)
runlevel (to lvl 5) 2.6.32-642.el6.x Tue Apr 1114:52 - 14:57 (00:04)
reboot system boot 2.6.32-642.el6.x TueApr 11 14:52 - 14:58 (00:05)
shutdown system down 2.6.32-642.el6.x Tue Apr 11 14:52- 14:52 (00:00)
runlevel (to lvl 0) 2.6.32-642.el6.x Tue Apr 1114:52 - 14:52 (00:00)