当前位置:   article > 正文

Centos7服务文件(.service)位置及案例介绍_centos7 service 目录

centos7 service 目录

Centos7服务文件(.service)位置及案例介绍

systemd:
CentOS 7的服务systemctl脚本存放在:/usr/lib/systemd/,有系统(system)和用户(user)之分,即:/usr/lib/systemd/system ,/usr/lib/systemd/user

每一个服务以.service结尾,一般会分为3部分:[Unit]、[Service]和[Install],就以httpd为例吧,具体内容如下:
 

  1. [root@localhost system]# pwd
  2. /usr/lib/systemd/system
  3. [root@localhost system]# cat httpd.service
  4. [Unit]
  5. Description=The Apache HTTP Server
  6. After=network.target remote-fs.target nss-lookup.target
  7. Documentation=man:httpd(8)
  8. Documentation=man:apachectl(8)
  9. [Service]
  10. Type=notify
  11. EnvironmentFile=/etc/sysconfig/httpd
  12. ExecStart=/usr/sbin/httpd $OPTIONS -DFOREGROUND
  13. ExecReload=/usr/sbin/httpd $OPTIONS -k graceful
  14. ExecStop=/bin/kill -WINCH ${MAINPID}
  15. # We want systemd to give httpd some time to finish gracefully, but still want
  16. # it to kill httpd after TimeoutStopSec if something went wrong during the
  17. # graceful stop. Normally, Systemd sends SIGTERM signal right after the
  18. # ExecStop, which would kill httpd. We are sending useless SIGCONT here to give
  19. # httpd time to finish.
  20. KillSignal=SIGCONT
  21. PrivateTmp=true
  22. [Install]
  23. WantedBy=multi-user.target
  24. [root@localhost system]# ll
  25. total 824
  26. -rw-r--r--. 1 root root 275 Aug 9 2019 arp-ethers.service
  27. -rw-r--r--. 1 root root 1384 Aug 8 2019 auditd.service
  28. lrwxrwxrwx. 1 root root 14 Jan 28 06:01 autovt@.service -> getty@.service
  29. -rw-r--r--. 1 root root 517 Oct 19 00:48 basic.target
  30. drwxr-xr-x. 2 root root 67 Feb 5 05:50 basic.target.wants
  31. -r--r--r--. 1 root root 429 Oct 19 00:05 blk-availability.service
  32. -rw-r--r--. 1 root root 379 Oct 19 00:48 bluetooth.target
  33. -rw-r--r--. 1 root root 160 Mar 29 2019 brandbot.path
  34. -rw-r--r--. 1 root root 116 Mar 29 2019 brandbot.service
  35. -rw-r--r--. 1 root root 787 Oct 19 00:48 console-getty.service
  36. -rw-r--r--. 1 root root 749 Oct 19 00:48 console-shell.service
  37. -rw-r--r--. 1 root root 808 Oct 19 00:48 container-getty@.service
  38. -rw-r--r--. 1 root root 294 Dec 7 00:00 cpupower.service
  39. -rw-r--r--. 1 root root 318 Aug 9 2019 crond.service
  40. -rw-r--r--. 1 root root 425 Oct 19 00:48 cryptsetup-pre.target
  41. -rw-r--r--. 1 root root 372 Oct 19 00:48 cryptsetup.target
  42. lrwxrwxrwx. 1 root root 13 Jan 28 06:01 ctrl-alt-del.target -> reboot.target
  43. lrwxrwxrwx. 1 root root 25 Jan 28 06:01 dbus-org.freedesktop.hostname1.service -> systemd-hostnamed.service
  44. lrwxrwxrwx. 1 root root 23 Jan 28 06:01 dbus-org.freedesktop.import1.service -> systemd-importd.service
  45. lrwxrwxrwx. 1 root root 23 Jan 28 06:01 dbus-org.freedesktop.locale1.service -> systemd-localed.service
  46. lrwxrwxrwx. 1 root root 22 Jan 28 06:01 dbus-org.freedesktop.login1.service -> systemd-logind.service
  47. lrwxrwxrwx. 1 root root 24 Jan 28 06:01 dbus-org.freedesktop.machine1.service -> systemd-machined.service
  48. lrwxrwxrwx. 1 root root 25 Jan 28 06:01 dbus-org.freedesktop.timedate1.service -> systemd-timedated.service
  49. -rw-r--r--. 1 root root 366 Mar 14 2019 dbus.service
  50. -rw-r--r--. 1 root root 102 Mar 14 2019 dbus.socket
  51. drwxr-xr-x. 2 root root 6 Oct 19 00:48 dbus.target.wants
  52. -rw-r--r--. 1 root root 1014 Oct 19 00:48 debug-shell.service
  53. lrwxrwxrwx. 1 root root 16 Jan 28 06:01 default.target -> graphical.target
  54. drwxr-xr-x. 2 root root 6 Oct 19 00:48 default.target.wants
  55. -rw-r--r--. 1 root root 670 Oct 19 00:48 dev-hugepages.mount
  56. -rw-r--r--. 1 root root 590 Oct 19 00:48 dev-mqueue.mount
  57. -r--r--r--. 1 root root 345 Oct 19 00:05 dm-event.service
  58. -r--r--r--. 1 root root 248 Oct 19 00:05 dm-event.socket
  59. lrwxrwxrwx. 1 root r
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/小丑西瓜9/article/detail/217453
推荐阅读
相关标签
  

闽ICP备14008679号