Redhat and CentOS using service control to start and shutdown

Source: Internet
Author: User
Tags centos

Sometimes, when we install a software ourselves, we want to make it easier to control the service, in Redhat/centos we will first think of using service XXX start|stop to implement, but unfortunately, this requires us to write the startup shutdown script, and add it to the startup list. It would be a lot easier if you could point to a shell script.

Nginx to explain its process, but the process, do not paste the shell script

1. Create a startup shutdown script in the/etc/init.d/directory, such as Nginx

2. When writing a script, there must be a chkconfig parameter in the script, such as: #chkconfig: 18 18 is preceded by a # start (same as annotations, but not annotations, followed by the level at which the boot needs to run, such as 2345, if you do not want to at any level, use "-", 18 18 The default sort number for S and K

Note:

S is the service to be opened when switching to this run level

K is the service to be closed when switching to a different run level

3. Give Nginx the right to execute this file

chmod +x/etc/init.d/nginx

4. Join Chkconfig

[root@nginxrc3.d]# chkconfig--add Nginx

If the following line of error occurs, the chkconfig row parameter in the second step is not added

Service Nginx does not support Chkconfig

5. This service can then be configured to run at which level

Chkconfig--level Nginx on

6. You can then use service Nginx start to start the

See more highlights of this column: http://www.bianceng.cnhttp://www.bianceng.cn/OS/Linux/

Related Article

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.