Search code examples
linuxmacosservicestatus

Command to get the service status of macOS


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.


Solution

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