[Linux] systemctl 列出來的 loaded active exited 是什麼意思?
今天在看 abrt 相關的 service 狀態,發現有個 loaded active exited,
不曉得那個 exited 是什麼意思:
root@localhost / # systemctl | egrep abrt
abrt-ccpp.service loaded active exited Install ABRT coredump hook
abrt-oops.service loaded active running ABRT kernel log watcher
abrtd.service loaded active running ABRT Automated Bug Reporting Tool
查了一下,原來是因為它沒有對應的 daemon 在執行,
例如可以看一下 /usr/lib/systemd/system/abrt-ccpp.service 的內容:
root@localhost / # cat /usr/lib/systemd/system/abrt-ccpp.service [Unit] Description=Install ABRT coredump hook After=abrtd.service Requisite=abrtd.service [Service] Type=oneshot ExecStart=/usr/sbin/abrt-install-ccpp-hook install ExecStop=/usr/sbin/abrt-install-ccpp-hook uninstall RemainAfterExit=yes [Install] WantedBy=multi-user.target
注意上面的 ExecStart 裡是去執行 abrt-install-ccpp-hook install 這個指令,
當執行完畢之後就結束了,因此對 systemd 來說是有成功執行 (active),
而只要 ExecStart 執行的指令結束後,就會變成 exited 了~
ip6tables 也是一個類似的例子,ExecStart 的指令是執行 ip6tables.init start,
執後完後就結束了,沒有 daemon 會持續持行,因此狀態也會是 active (exited):
root@localhost / # systemctl status ip6tables ip6tables.service - IPv6 firewall with ip6tables Loaded: loaded (/usr/lib/systemd/system/ip6tables.service; enabled) Active: active (exited) since Thu 2016-01-28 11:45:13 CST; 1 months 22 days ago Main PID: 956 (code=exited, status=0/SUCCESS) CGroup: /system.slice/ip6tables.service root@localhost / # egrep ExecStart /usr/lib/systemd/system/ip6tables.service ExecStart=/usr/libexec/iptables/ip6tables.init start
參考資料:
What does status “active (exited)” mean for a (custom) service?
systemd FAQ: Status of .service says “active (exited)” in green. (e.g. iptables)
(本頁面已被瀏覽過 5,558 次)