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