Linux Services boot up

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.