从这个改变如何更改Linux服务的启动/启动顺序? 改变符号链接的值显然启动顺序被改变。
在我们使用的debian衍生产品中
update-rc.d apache2默认20 80
我们在Centos / Redhat中有类似的命令吗?
如果是的话是什么?
在init脚本头文件中应该做些什么改变?
注意:我应该使用init系统(不是任何systemd或暴发户)
另一种方法是直接在服务初始化脚本中更改以# chkconfig:开头的行。 这在chkconfig(8)手册页中进行了解释。
运行级文件
每个应该由chkconfigpipe理的服务需要在其init.d脚本中添加两个或多个注释行。 第一行告诉chkconfig默认启动服务的运行级别,以及启动和停止优先级。 如果服务不应该默认在任何运行级别启动,则应该使用a – 来代替运行级别列表。 第二行包含服务的描述,并可以通过反斜杠延续的多行进行扩展。
例如,random.init有这三行:
# chkconfig: 2345 20 80 # description: Saves and restores system entropy pool for \ # higher quality random number generation.这就是说,随机脚本应该在第2,3,4和5级开始,它的开始优先级应该是20,停止优先级应该是80.你应该能够弄清楚说明是什么, 导致线路继续。 行前的额外空间被忽略。
在更改脚本之后,如果需要使用该服务的reset选项运行chkconfig命令(以root身份)。 通过“重置”,chkconfig将自动在给定优先级的configuration运行级别中创build启动/停止符号链接。
您可以手动重命名/etc/rcX.d目录中的符号链接来更改引导顺序。
UPD:在RHEL / CentOS下,使用命令ntsysv或chkconfig。
我想添加更多的细节,以上的答案
为了开始特别是在centos中的脚本,没有像这样的替代scheme
update-rc.d
在Debain,
最简单的方法是按照此处所述手动更改脚本,例如/etc/init.d/postfix中的代码
#!/bin/bash # # postfix Postfix Mail Transfer Agent # # chkconfig: 2345 80 30 # description: Postfix is a Mail Transport Agent, which is the program \ # that moves mail from one machine to another. # processname: master # pidfile: /var/spool/postfix/pid/master.pid # config: /etc/postfix/main.cf # config: /etc/postfix/master.cf # # Based on startup script from Simon J Mudd <[email protected]> # 25/02/99: Mostly s/sendmail/postfix/g by John A. Martin <[email protected]> # 23/11/00: Changes & suggestions by Ajay Ramaswamy <[email protected]> # 20/01/01: Changes to fall in line with RedHat 7.0 style # 23/02/01: Fix a few untidy problems with help from Daniel Roesen. ### BEGIN INIT INFO # Provides: postfix MTA # Required-Start: $local_fs $network $remote_fs # Required-Stop: $local_fs $network $remote_fs # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Description: start and stop postfix # Description: Postfix is a Mail Transport Agent, which is the program that # moves mail from one machine to another. ### END INIT INFO