Status of specific brew service

Switching between various development environments, to save restart time, I wanted to start various services from OS/X only if they were not already running. Brew does not have a method to know whether a particular service is running (AFAIK), so the following example code parses the list of services returned by brew services list and then enables quickly checking the status of a given service and acting accordingly:

brew services list | awk -F " " '{print $1 "=\"" $2 "\""}' >
chmod u+x
source ./ # so that variables are maintained in this shell
rm ./

if [ "$php72" == "started" ]; then
        echo "PHP service is up"

if [ "$openresty" == "started" ]; then
        echo "Openresty service is up"

Leave a Reply

Your email address will not be published. Required fields are marked *