About centos7 adding a service as a system service

Source: Internet
Author: User
  1. 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

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.