ansheng’s blog!

macOS服务管理brew services用法

macOS中的brew services类似于CentOS 7下的systemctl,主要是用来管理服务的一些操作。

基本操作

下面的操作以nginx为例

$ brew install nginx
$ brew uninstall nginx
$ brew upgrade nginx
$ brew reinstall nginx
$ brew services list
$ brew services run nginx
$ brew services start nginx
$ brew services stop nginx
$ brew services restart nginx
$ brew services cleanup

注册服务

注册开机自启后,会创建.plist文件,该文件包含版本信息、编码、安装路径、启动位置、日志路径等信息,取消自启动后会自动删除,执行 brew services list 可以看到各个服务该文件的存放位置

.plist存放目录

/Library/LaunchDaemons/
~/Library/LaunchDaemons/