Reboot與init 6的差別
起因在于:重新開機伺服器後有時候服務不會啟動,而有時候又可以自動運作,唯一差别在于重新開機指令用的是reboot還是init 6.
後查了相關資料,竟然大有玄機:
對這兩個操作使用man指令看到的内容如下:
init 6 Stop the operating system and reboot to the state defined by the initdefault entry in /etc/inittab.
reboot - reboot performs a sync(1M) operation on the disks, and then a
multi- user reboot is initiated. See init(1M) for details.
"init 6" 基于一系列/etc/inittab檔案,并且每個應用都會有一個相應shutdown腳本。
'init 6' 調用一系列shutdown腳本(/etc/rc0.d/K*)來使系統優雅關機;
'reboot'并不執行這些過程,reboot更是一個 kernel級别的指令,不對應用使用shutdown腳本。 .
我們應該在通常情況下使用 init 6.
在出問題的狀況下或強制重新開機 時使用reboot.
reboot is a more aggresive command to use. init 6 is much graceful
use of `init 6` will give the cleanest and orderly reboot (init informs svc.startd of the runlevel change and will move to the appropriate milestone).
use of `shutdown -y -g0 -i6 **message**` will invoke init as well as give you grace period and messages to user (shutdown invoked the same as init above).
halt,reboot,poweroff will not run any of the shutdown scripts and should be last resort.
本文轉自holy2009 51CTO部落格,原文連結:http://blog.51cto.com/holy2010/405495