大网数据广告活动
服务器运维问答

how to change the startup order of linux init scripts in Redhat, Centos

· 52CE 我爱测

From this changing How to change Linux services startup/boot order? changing the values of the symbolic links it is evident that startup order is changed. In debian derivatives we use update-rc.d apache2 defaults 20 80 Do we have…

问题原文

原帖链接 · forum.test17 · CC BY-SA 3.0

From this changing How to change Linux services startup/boot order? changing the values of the symbolic links it is evident that startup order is changed.

In debian derivatives we use

update-rc.d apache2 defaults 20 80

Do we have similar command in Centos/Redhat and ?

if so what it is ?

and what should be possible changes in init scripts header ?

Note: I should use init system (not any systemd or upstart)

已采纳解答

原帖链接 · Diamond · CC BY-SA 3.0

An alternative will be to change the line starting with # chkconfig: in the service init script directly. This is explained in the chkconfig(8) man page.

Runlevel Files

Each service which should be manageable by chkconfig needs two or more commented lines added to its init.d script. The first line tells chkconfig what runlevels the service should be started in by default, as well as the start and stop priority levels. If the service should not, by default, be started in any runlevels, a - should be used in place of the runlevels list. The second line contains a description for the service, and may be extended across multiple lines with backslash continuation.

For example, random.init has these three lines:

# chkconfig: 2345 20 80
# description: Saves and restores system entropy pool for \
#              higher quality random number generation.

This says that the random script should be started in levels 2, 3, 4, and 5, that its start priority should be 20, and that its stop priority should be 80. You should be able to figure out what the description says; the \ causes the line to be continued. The extra space in front of the line is ignored.

After changing the script, if you will need to run the chkconfig command (as root) with the reset option for that service. With "reset", chkconfig will automatically create start/stop symlinks in the configured run levels with given priorities.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2016-02-08)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。