Centos System Services Script directory:
[Plain]View PlainCopy
- /usr/lib/systemd/
System and users (user),
If you need to boot the program can be run without logging in, there is system services (systems), that is:
[Plain]View PlainCopy
- lib/systemd/system/
Conversely, the user login to run the program, the presence of users (user)
The service ends with a. Service.
This is an example of an nginx boot operation.
1. Create a service file
[Plain]View PlainCopy
- Vim/lib/systemd/system/nginx.service
[Plain]View PlainCopy
- [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]
- Wantedby=multi-user.target
[Unit]: Description of the service
Description: Description Service
After: Describe the service category
settings for the [service] service run parameter
Type=forking is the form of a background run
Execstart specific run commands for the service
Execreload Reset Command
Execstop for Stop command
Privatetmp=true represents a separate temporary space allocated to the service
Note: The start, restart, and stop commands for [Service] all require absolute paths
[Install] Service installation settings, can be set to multi-user Linux learning,/HTTP/linux.it.net.cn
2. Save the Directory
Save in Directory with 754 permissions:
[Plain]View PlainCopy
- /lib/systemd/system
3. Set up boot from boot
[Plain]View PlainCopy
- Systemctl Enable Nginx.service
4. Other commands
Task |
Old instructions |
New directives |
Enable a service to 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 only active) |
Show all services that have been started |
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
[Plain]View PlainCopy
- Systemctl Start Nginx.service
Set up boot from
[Plain]View PlainCopy
- Systemctl Enable Nginx.service
Stop Boot from booting
[Plain]View PlainCopy
- Systemctl Disable Nginx.service
View the current status of the service
[Plain]View PlainCopy
- Systemctl Status Nginx.service
Restart Service
[Plain]View PlainCopy
- Systemctl Restart Nginx.service
View all services that have been started
[Plain]View PlainCopy
- Systemctl list-units--type=service
Go MySQL database binlog log usage summary centos 7.x Setup Custom boot, add custom system service