14

If I run the command "service --status-all", each (running?) service is listed in column format. The first column has either a [ ? ], [ + ], or [ - ] before the service name. What does this column represent? What does ?, +, and - mean?

Sorry if this is a simple question. I searched online for ~30 minutes before just coming here and asking.

I even found this: What do the symbols in service --status-all mean? where the "correct" answer states "It draws a [ + ] or [ - ] depending on whether the exit status was zero or nonzero, respectively.".

So, I guess my new question is what does status zero and nonzero(!?!?!) mean?

00fruX
  • 1,271
  • 1
  • 16
  • 32

1 Answers1

13

Well those are just exit codes. After something has done running, it can return an 8-bit integer (0-255) to indicate how it exited.

  • Zero (which is implied if nothing is returned) means the application got to the end of what it was supposed to do and exited naturally.
  • Non-zero codes (1-255) can mean whatever the application wants. The man page (man <command>) will usually show you what these codes mean.

In terms of the question, don't overthink it:

  • + means it's running,
  • - means it isn't (it might have crashed - it might never have started), and
  • ? means the services doesn't have a status command, so there's no way the service command can work out what's what.
Oli
  • 293,335
  • 1
    I totally agree with your answer (+1), but I just can't understand why sudo service --status-all 2>&1 | grep ssh outputs [ - ] ssh even when I run this command from SSH? Or why sudo service --status-all 2>&1 | grep lightdm outputs [ ? ] lightdm when sudo service lightdm status works like a charm? – Radu Rădeanu Mar 20 '14 at 18:18
  • @RaduRădeanu To guess, I think might be is a legacy /etc/init.d issue. On my serially upgraded computer, /etc/init.d/ssh status; echo $? shows non-zero (bad, not running) and initctl list doesn't show SSH. On my 14.04 box initctrl does show SSH but service still can't read the status. Also remember that initctrl works for Upstart and service is part of sysvinit-utils. It's not the clearest of pictures but I think that might go some way to explain some of the quirks. I'm sure the move to systemd will clear everything up D: – Oli Mar 20 '14 at 23:19
  • I thought a negative exit code could be returned as well, or is that for non-service scripts only? – saiarcot895 Jul 03 '14 at 02:36