CentOS 7.x Set Custom boot up, add custom system services

Source: Internet
Author: User

Centos System Services Script directory:

/usr/lib/systemd/  
The system and user points,

In the case of a program that is capable of running without landing, there is a system service, which is:

lib/systemd/system/  
Conversely, the user can log in to run the program, there are users (user)

Service ends with. Service.

This side with Nginx boot Run for example IT 1. Establishing Service Files

[Unit]  
Description=nginx  
after=network.target  
   
[Service]  
type=forking  
execstart=/www/lanmps/init.d/ Nginx start  
execreload=/www/lanmps/init.d/nginx restart  
execstop=/www/lanmps/init.d/nginx  stop  
privatetmp=true  
   
[Install]  

[Unit]: Description of the service

Description: Describing services
After: Description of service categories

Settings for running parameters for service services

Type=forking is the form of background running
Execstart the specific Run command for the service
Execreload reboot Command
Execstop to stop command
Privatetmp=true represents a temporary space for a service to be allocated independently
Note: The start, restart, and stop commands for service are all required to use absolute paths

[Install] Service installation settings that can be set up for multi-user Linux learning, http://linux.it.net.cn 2. Save Directory

Save in Directory with 754 permissions:

/lib/systemd/system

3. Set power-on self-starter
Systemctl Enable Nginx.service

4. Other Orders
Task Old instructions New instructions
Make a service start automatically Chkconfig--level 3 httpd on Systemctl Enable Httpd.service
Make a service not start automatically Chkconfig--level 3 httpd off Systemctl Disable Httpd.service
Check Service status Service httpd Status Systemctl Status Httpd.service (service details)
Systemctl is-active Httpd.service (show whether active only)
Show all started services Chkconfig--list Systemctl list-units--type=service
Start a service Service httpd Start Systemctl Start Httpd.service
Stop a service Service httpd Stop Systemctl Stop Httpd.service
Restart a service Service httpd Restart Systemctl Restart Httpd.service
Start Nginx Service I
Systemctl Start Nginx.service

Set up startup

Systemctl Enable Nginx.service
Stop power-on Self start

Systemctl Disable Nginx.service
To view the current status of a service

Systemctl Status Nginx.service
Restart Service

View all services that have started
Systemctl list-units--type=service






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.