First, we will introduce the system service startup and shutdown changes in centos7.
Service name start/stop/status = systemctl start/stop/status service name
Chkconfig -- list = systemctl list-units-type
Chkconfig service name on/off = systemctl enable/disable service name (the specific level depends on the configuration file)
2. To add a service as a system service (using nginx as an example), you need to add a file ending with. Service, which is much easier than the previous sysv.
[[Email protected] ~] # Vim/usr/lib/systemd/system/nginx. Service
[Unit]
Description = Web Service
Afterdomainnetwork.tar get
[SERVICE] // The service content is very important and must be an absolute path
Pidfile =/usr/local/nginx/logs/nginx. PID // location where the PID file is stored
Execstart =/usr/local/nginx/sbin/nginx // start command
Execstop =/usr/local/nginx/sbin/nginx-S Stop // close the command
Execreload =/usr/local/nginx/sbin/nginx-s reload // heavy load command
Privatetmp = true
[Install] // It is required. If it is not added as the start time, an error will be reported.
Wantedby=default.tar get // similar to the previous -- level 35, the current target is equivalent to the previous running level