0

According to

How to read "service --status-all" results

service --status-all

list the running services with [+]. On the other hand, you can check the status of a service with

service <name> status

Now 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
  [+] apparmor

Why is that, what is correct now or have I overlooked anything?

1
  • 1
    Please don't do this Post the solution as an ANSWER.
    – Rinzwind
    May 15, 2020 at 21:34

1 Answer 1

0

Solution

Translated from: https://forum.ubuntuusers.de/topic/laufender-service-ja-oder-nein/

This is a very good example of why you shouldn't use the service command since systemd (and thus systemctl) was introduced.

You can look at the source code of the service command (/usr/sbin/service). With the --status-all option, this script changes to /etc/init.d and 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 is 0 and the length of the recorded output is not zero. Before that, it is tested whether the output of the executed file contains the string usage: (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 $?
0

If 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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .