赞
踩
systemd:
CentOS 7的服务systemctl脚本存放在:/usr/lib/systemd/,有系统(system)和用户(user)之分,即:/usr/lib/systemd/system ,/usr/lib/systemd/user
每一个服务以.service结尾,一般会分为3部分:[Unit]、[Service]和[Install],就以httpd为例吧,具体内容如下:
- [root@localhost system]# pwd
- /usr/lib/systemd/system
- [root@localhost system]# cat httpd.service
- [Unit]
- Description=The Apache HTTP Server
- After=network.target remote-fs.target nss-lookup.target
- Documentation=man:httpd(8)
- Documentation=man:apachectl(8)
-
- [Service]
- Type=notify
- EnvironmentFile=/etc/sysconfig/httpd
- ExecStart=/usr/sbin/httpd $OPTIONS -DFOREGROUND
- ExecReload=/usr/sbin/httpd $OPTIONS -k graceful
- ExecStop=/bin/kill -WINCH ${MAINPID}
- # We want systemd to give httpd some time to finish gracefully, but still want
- # it to kill httpd after TimeoutStopSec if something went wrong during the
- # graceful stop. Normally, Systemd sends SIGTERM signal right after the
- # ExecStop, which would kill httpd. We are sending useless SIGCONT here to give
- # httpd time to finish.
- KillSignal=SIGCONT
- PrivateTmp=true
-
- [Install]
- WantedBy=multi-user.target
- [root@localhost system]# ll
- total 824
- -rw-r--r--. 1 root root 275 Aug 9 2019 arp-ethers.service
- -rw-r--r--. 1 root root 1384 Aug 8 2019 auditd.service
- lrwxrwxrwx. 1 root root 14 Jan 28 06:01 autovt@.service -> getty@.service
- -rw-r--r--. 1 root root 517 Oct 19 00:48 basic.target
- drwxr-xr-x. 2 root root 67 Feb 5 05:50 basic.target.wants
- -r--r--r--. 1 root root 429 Oct 19 00:05 blk-availability.service
- -rw-r--r--. 1 root root 379 Oct 19 00:48 bluetooth.target
- -rw-r--r--. 1 root root 160 Mar 29 2019 brandbot.path
- -rw-r--r--. 1 root root 116 Mar 29 2019 brandbot.service
- -rw-r--r--. 1 root root 787 Oct 19 00:48 console-getty.service
- -rw-r--r--. 1 root root 749 Oct 19 00:48 console-shell.service
- -rw-r--r--. 1 root root 808 Oct 19 00:48 container-getty@.service
- -rw-r--r--. 1 root root 294 Dec 7 00:00 cpupower.service
- -rw-r--r--. 1 root root 318 Aug 9 2019 crond.service
- -rw-r--r--. 1 root root 425 Oct 19 00:48 cryptsetup-pre.target
- -rw-r--r--. 1 root root 372 Oct 19 00:48 cryptsetup.target
- lrwxrwxrwx. 1 root root 13 Jan 28 06:01 ctrl-alt-del.target -> reboot.target
- lrwxrwxrwx. 1 root root 25 Jan 28 06:01 dbus-org.freedesktop.hostname1.service -> systemd-hostnamed.service
- lrwxrwxrwx. 1 root root 23 Jan 28 06:01 dbus-org.freedesktop.import1.service -> systemd-importd.service
- lrwxrwxrwx. 1 root root 23 Jan 28 06:01 dbus-org.freedesktop.locale1.service -> systemd-localed.service
- lrwxrwxrwx. 1 root root 22 Jan 28 06:01 dbus-org.freedesktop.login1.service -> systemd-logind.service
- lrwxrwxrwx. 1 root root 24 Jan 28 06:01 dbus-org.freedesktop.machine1.service -> systemd-machined.service
- lrwxrwxrwx. 1 root root 25 Jan 28 06:01 dbus-org.freedesktop.timedate1.service -> systemd-timedated.service
- -rw-r--r--. 1 root root 366 Mar 14 2019 dbus.service
- -rw-r--r--. 1 root root 102 Mar 14 2019 dbus.socket
- drwxr-xr-x. 2 root root 6 Oct 19 00:48 dbus.target.wants
- -rw-r--r--. 1 root root 1014 Oct 19 00:48 debug-shell.service
- lrwxrwxrwx. 1 root root 16 Jan 28 06:01 default.target -> graphical.target
- drwxr-xr-x. 2 root root 6 Oct 19 00:48 default.target.wants
- -rw-r--r--. 1 root root 670 Oct 19 00:48 dev-hugepages.mount
- -rw-r--r--. 1 root root 590 Oct 19 00:48 dev-mqueue.mount
- -r--r--r--. 1 root root 345 Oct 19 00:05 dm-event.service
- -r--r--r--. 1 root root 248 Oct 19 00:05 dm-event.socket
- lrwxrwxrwx. 1 root r
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。