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

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


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

Tags:

Services