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)

相关内容