According to
How to read "service --status-all" results
service --status-alllist the running services with [+]. On the other hand, you can check the status of a service with
service <name> statusNow both commands list the service apache-htcacheclean for me
differently.
✗ ✗ sudo service apache-htcacheclean status
● apache-htcacheclean.service - Disk Cache Cleaning Daemon for Apache HTTP Server Loaded: loaded (/lib/systemd/system/apache-htcacheclean.service; disabled; vendor preset: enabled) Active: inactive (dead)
✗ ✗ sudo service --status-all [+] acpid [-] alsa-utils [-] anacron [+] apache-htcacheclean [-] apache2 [+] apparmorWhy is that, what is correct now or have I overlooked anything?
11 Answer
Solution
Translated from:
This is a very good example of why you shouldn't use the
servicecommand sincesystemd(and thussystemctl) was introduced.You can look at the source code of the
servicecommand (/usr/sbin/service). With the--status-alloption, this script changes to/etc/init.dand executes each executable file located there with a previously defined environment and the argument status. From this call, the return value and the output are saved.A service receives the marker
[+]if the return value of the executed program is0and the length of the recorded output is not zero. Before that, it is tested whether the output of the executed file contains the stringusage:(upper and lower case is ignored) in order to use the marker[?]to put. For all other cases the result is[-].Now an example:
/etc/init.d$ ls
acpid console-setup.sh grub-common lvm2 mdadm-waitidle plymouth-log ssh
apache2 cron hwclock.sh lvm2-lvmetad networking procps udev
apache-htcacheclean cryptdisks irqbalance lvm2-lvmpolld nfs-common rpcbind ufw
apparmor cryptdisks-early iscsid lxcfs open-iscsi rsync uuidd
apport dbus keyboard-setup.sh lxd open-vm-tools rsyslog
atd ebtables kmod mdadm plymouth screen-cleanup
/etc/init.d$ ./apache-htcacheclean status * apache-htcacheclean is not running
/etc/init.d$ echo $?
0If you ask service directly about the status of a service, it will instead be passed through a systemctl, which can then give a much more correct answer.