Redhat/centos using service control to start and close

Source: Internet
Author: User

Original address: http://guodong810.blog.51cto.com/4046313/1285353

Sometimes, when we install a software ourselves, we want to make this service easier to control, 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 added to the startup list. It would be a lot easier if you would order a shell script.

With Nginx to explain its process, just 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 scripting, there must be chkconfig parameters in the script, such as: #chkconfig:-18 18 The front is preceded by the # (and comments, but not comments, followed by the boot needs to run the level, such as 2345, if you do not want to be on at any level, then use "-", 18 18 indicates the default sort number for S and K

Note:

S is the service to turn on when switching to this run level

K is the service to shut down when switching to another runlevel

3. Permission to perform this file for Nginx

chmod +x/etc/init.d/nginx

4. Join Chkconfig

[Email protected]]# chkconfig--add Nginx

If the following line error occurs, the Chkconfig parameter in the second step is not added

Service Nginx does not support Chkconfig

5. Next, you can configure this service to run at which level

Chkconfig--level

6. Next, you can use the service Nginx start to launch the

Redhat/centos using service control to start and close

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.