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。
[root@lyp ~]# 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)