16

Here is the command to get the service status on Linux:

service ${services} status

I want the command to get the service status on macOS. Any help would be appreciated.

informatik01
  • 16,038
  • 10
  • 74
  • 104
Melvin Moses
  • 407
  • 2
  • 6
  • 17

3 Answers3

33

You only are able to list the services:

sudo launchctl list

Mix it with some grep and you have it.

sudo launchctl list | grep service <-- Here you put the service you're looking for

The output has the following meaning:

  • First number is the PID of the process, if it's running, if it isn't running, it shows a '-'.
  • Second number is the exit code of the process, if it has finished. If it's negative, it's the number of the kill signal.
  • The third column is the process name.
Eduardo Yáñez Parareda
  • 9,126
  • 4
  • 37
  • 50
  • Can you pls give the full code with grep. That would be more helpful. – Melvin Moses Apr 14 '16 at 11:13
  • I have mixed it with grep command, but I got some integer values (mostly zeros ) in the status field. How can I be assure that service is running or stopped. – Melvin Moses Apr 14 '16 at 11:18
  • Thanks for your input. As you said pid shows '-' is stopped service and the services that have integer pid is in running state. Is that correct. – Melvin Moses Apr 19 '16 at 08:54
6

You can try this.

brew services info service_name

E.g., I'd like to know RabbitMQ state

brew services info rabbitmq

It will show like this: Service info

Francis iz me
  • 61
  • 1
  • 1
5

Simple brew services list will do the trick

Sankeerna Reddy
  • 161
  • 2
  • 8