LinuxCommandLibrary

brew-services

Manage Homebrew-installed services

TLDR

List all managed services for the current user

$ brew services
copy

List more information about all managed services
$ brew services info --all
copy

Start a service immediately and register it to launch at login (or boot)
$ brew services start [formula]
copy

Stop the service immediately and unregister it from launching at login (or boot)
$ brew services stop [formula]
copy

Stop (if necessary) and start the service immediately and register it to launch at login (or boot)
$ brew services restart [formula]
copy

Remove all unused services
$ brew services cleanup
copy

SYNOPSIS

brew services [subcommand] [service_name]

PARAMETERS

list
    Lists all services managed by Homebrew with their status (started, stopped, error).

start [service_name]
    Starts the specified service. If no service name is given, it starts all installed Homebrew services.

stop [service_name]
    Stops the specified service. If no service name is given, it stops all installed Homebrew services.

restart [service_name]
    Restarts the specified service. If no service name is given, it restarts all installed Homebrew services.

run [service_name]
    Runs the service in the foreground. Useful for debugging.

cleanup
    Removes stale service files.

home
    Opens the Homebrew homepage in the default browser.

--all
    Modifies other command to run on all services, for example, brew services stop --all

DESCRIPTION

The brew services command is a Homebrew extension that simplifies managing background services on macOS. It provides a user-friendly interface to start, stop, restart, and list services managed by Homebrew's service management capabilities. This command relies on macOS's launchd system for managing services. It streamlines the process of creating and managing plist files (property list files) that define how services are launched and maintained. This tool eliminates the need to manually create and edit plist files or interact directly with launchctl, the command-line interface to launchd, therefore, making it a convenient way to manage services within the Homebrew ecosystem. It improves over direct launchctl use as the command is aware of Homebrew's managed files and the user context.

CAVEATS

This command only manages services installed via Homebrew. Services started with `brew services run` run in the foreground and are terminated when the terminal session ends.

<I>SERVICE PLIST FILES</I>

The command manages plist files typically located in /Library/LaunchDaemons or ~/Library/LaunchAgents (depending on the installation context).

<I>TROUBLESHOOTING</I>

If a service fails to start, check the system logs using the log stream command or examine the service's log files (if configured) for error messages.

HISTORY

The brew services command was introduced as a Homebrew extension to simplify service management. It replaced more cumbersome methods of interacting with launchd. The development focused on providing a more user-friendly and Homebrew-aware interface for managing background processes.

SEE ALSO

launchctl(1), brew(1)

Copied to clipboard