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

Solution 1:

The output of service --status-all lists the state of services controlled by System V.

The + indicates the service is running, - indicates a stopped service. You can see this by running service SERVICENAME status for a + and - service.

Some services are managed by Upstart. You can check the status of all Upstart services with sudo initctl list. Any service managed by Upstart will also show in the list provided by service --status-all but will be marked with a ?.

Reference: man service

Solution 2:

It's not documented in the manpage, but a quick look at the source confirms the first guess:

  • +: the service is running
  • -: the service is not running
  • ?: the service state cannot be determined (for some reason).

The actual code:

 if ! is_ignored_file "${SERVICE}" \
 && [ -x "${SERVICEDIR}/${SERVICE}" ]; then
         if ! grep -qs "\(^\|\W\)status)" "$SERVICE"; then
           #printf " %s %-60s %s\n" "[?]" "$SERVICE:" "unknown" 1>&2
           echo " [ ? ]  $SERVICE" 1>&2
           continue
         else
           out=$(env -i LANG="$LANG" PATH="$PATH" TERM="$TERM" "$SERVICEDIR/$SERVICE" status 2>&1)
           if [ "$?" = "0" -a -n "$out" ]; then
             #printf " %s %-60s %s\n" "[+]" "$SERVICE:" "running"
             echo " [ + ]  $SERVICE"
             continue
           else
             #printf " %s %-60s %s\n" "[-]" "$SERVICE:" "NOT running"
             echo " [ - ]  $SERVICE"
             continue
           fi
         fi
   #env -i LANG="$LANG" PATH="$PATH" TERM="$TERM" "$SERVICEDIR/$SERVICE" status
 fi

The conditions are:

  • if the init script doesn't support a status command, the state is ?.
  • if the init script (with the status argument) exit status is zero and output is not empty, the state is +.
  • otherwise the state is -.

Solution 3:

I believe that + means the service is active/running, - means it is inactive/stopped, and ? means that the command cannot conclusively determine whether it is active or not, as the service does not have a status command in the service script. The service --status-all command actually runs service <service-name> status for every available service.