1, chkconfig configuration Boot
Create an executable script that executes the service in/ETC/INIT.D, giving the script executable permissions. If it is installed through Yum or RPM, and there is a corresponding startup script in that directory, you do not have to create it yourself.
A service that requires power-on start-up via Chkconfig must have an executable script created in the/ETC/INIT.D directory, and the service name is the script name.
Each service managed by Chkconfig needs to add two or more lines of comments to the script under the corresponding INIT.D.
# Chkconfig:chkconfig The default startup run level and the start and stop priority.
# Description: Description of the service, you can use the \ cross-line comment.
These two lines of comments must have
/etc/init.d/my-service just simulate, service execution just output number 123
#! /bin/bash# chkconfig:2345 80# description:saves and restores system entropy pool for # higher quality random number G Eneration.echo 123;
chkconfig:2345 20 80 indicates that the service runs at run level 2345 and 20 means that the boot priority weight of 80 indicates the turn off precedence. The Chkconfig--add command is actually a soft connection to the startup script in/ETC/INIT.D
/ETC/RC.D/RC3.D (Rc0.d ... rc6.d) 0-6 run levels corresponding to the corresponding directory. are soft connections that start scripts in/ETC/INIT.D.
Set executable permissions to script My-service and add boot services via Chkconfig
chmod +x/etc/init.d/my-servicechkconfig--add My-service
The script in/etc/init.d/can be ordered by:
Service Service-name [Start/stop] starts or shuts down. If you are writing your own startup script, you need to learn how to write the shell, which is actually written using the case command.
For example
Service Nginx Start
2. Add the boot command to the/etc/rc.local file. when booting up, execute the/ETC/RCX.D (x represents a number from 0 to 6, corresponding to the 7 RunLevel startup directory), finally execute the/etc/rc.local script, we will start the service script to write to this file. Check whether the file has executable permissions if it does not take effect
#!/bin/*after*inif you don'tdo/var /lock/subsys/local# need to execute the script to write the absolute path /usr/local/rabbitmq_server-3.6. 3/sbin/rabbitmq-server detached &
Linux Services boot up