歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
您现在的位置: Linux教程網 >> UnixLinux >  >> Linux基礎 >> Linux教程

SUSE 與 RedHat init.d 腳本文件的區別

Linux下,子啟動服務需要在/etc/init.d目錄下生成腳本文件,用以響應start/stop/restart操作。

Linux在啟動時,有幾個不同的run level,分別為0~6.

0  Halt Shuts down the system.
1  Single-User Mode Mode for administrative tasks
2  Multi-User Mode Does not configure network interfaces and does not export networks services.
3  Multi-User Mode with Networking Starts the system normally
4  Not used/User-definable For special purposes.
5  Start the system normally with appropriate display manager. As runlevel 3 + display manager .
6  Reboot Reboots the system.

我們需要告訴系統在什麼級別下運行某個服務,以及運行的次序。

RedHat下,通過在init.d 腳本文件中如下指定:#chkconfig 345 20 80, 其中,345表示在run level3,4,5啟動該服務,20表示啟動優先級,80表示關閉優先級。

而在SUSE下使用isserv來加載服務,使用如下格式:

### BEGIN INIT INFO
# Provides:          FOO
# Required-Start:    $syslog $remote_fs
# Required-Stop:     $syslog $remote_fs
# Default-Start:     3 5
# Default-Stop:      0 1 2 6
# Description:       Start FOO to allow XY and provide YZ
### END INIT INFO這裡有一點不同,chkconfig通過制定優先級來確定啟動順序,insserv通過制定依賴的服務來制定。

我們可以在/etc/insserv.conf中找到可以使用的系統模塊名稱:$syslog, $network, $time, $portmap, $local_fs, $ALL表示所有服務, $null 表示空

*_Stop如果為空,默認和*_Start一致。可以使用$null設置為空。

LSB(Linux Standard Base Specification)

insserv (init system service)

Copyright © Linux教程網 All Rights Reserved