摘要:使用brew services
指令,管理 brew 后台服务,实现服务状态查询、启动与关闭。
列出当前用户所有托管服务信息 1 [sudo] brew services [list] (--json)
示例:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 Name Status User File elasticsearch-full started legalgeek ~/../homebrew.mxcl.elasticsearch-full.plist kibana-full started legalgeek ~/../homebrew.mxcl.kibana-full.plist [ { "name" : "elasticsearch-full" , "status" : "started" , "user" : "legalgeek" , "file" : "/Users/legalgeek/Library/LaunchAgents/homebrew.mxcl.elasticsearch-full.plist" , "exit_code" : 0 }, { "name" : "kibana-full" , "status" : "started" , "user" : "legalgeek" , "file" : "/Users/legalgeek/Library/LaunchAgents/homebrew.mxcl.kibana-full.plist" , "exit_code" : 0 } ]
列出当前用户所有托管服务 1 [sudo] brew services info (*formula*|--all|--json)
示例:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 elasticsearch-full (homebrew.mxcl.elasticsearch-full) Running: ✔ Loaded: ✔ Schedulable: ✘ User: legalgeek PID: 3598 kibana-full (homebrew.mxcl.kibana-full) Running: ✔ Loaded: ✔ Schedulable: ✘ User: legalgeek PID: 3835
运行服务,无需注册登录(或启动)时启动 1 [sudo] brew services run (*formula*|--all)
启动服务,并将其注册为在登录(或启动)时启动 1 [sudo] brew services start (*formula*|--all)
示例:
1 brew services start elastic/tap/elasticsearch-full
停止服务,并在登录(或启动)时注销它 1 [sudo] brew services stop (*formula*|--all)
示例:
1 brew services stop elastic/tap/elasticsearch-full
重启服务,并将其注册到登录(或引导)启动 1 [sudo] brew services restart (*formula*|--all)
示例:
1 brew services restart elastic/tap/elasticsearch-full
删除所有未使用的服务 1 2 3 4 5 [sudo] brew services cleanup --file: Use the plist file from this location to start or run the service. --all: Run *subcommand* on all services. --json: Output as JSON.