6
7

More than 1 year has passed since last update.

brew servicesの使い方

Posted at

前書き

systemdに慣れる方には、brew serviceはよく紛らわしい存在かなと思います。サービスの「起動」と「自動起動の有効化」が一つのコマンドに纏められたので、知ってる方には便利だけど、逆に動作がわからない感じもう生じますね。

コマンド

[sudo] brew services [サブコマンド]

macOSのlaunchctl(1)デーモンマネージャーを使用して、バックグラウンドサービスを管理します。

sudoが指定された場合、/Library/LaunchDaemons(起動時に開始)で操作します。そうでない場合は、~/Library/LaunchAgents(ログイン時に開始)で操作します。

brew services [list] (--json)

現在のユーザー(またはroot)のサービス一覧を表示します。listは指定しなくてもいいです。

brew services info (サービス名|--all|--json)

サービスの詳細情報します。

$ brew services info mysql
mysql (homebrew.mxcl.mysql)
Running: ✘
Loaded: ✘
Schedulable: ✘

brew services run (サービス名|--all)

サービスを起動します。

brew services start (サービス名|--all|--file=)

サービスを起動し、ログイン時にも自動起動するように登録します。

brew services kill (サービス名|--all)

サービスを停止します。

brew services stop (サービス名|--all)

サービスを停止し、ログイン時に自動起動の登録を解除します。

brew services restart (サービス名|--all)

サービスを再起動し、ログイン時にも自動起動するように登録します。

brew services cleanup

未使用のすべてのサービスを削除します。

オプション

  • --all:すべてのサービスに対してサブコマンドを実行します。
  • --json:JSON形式で出力します。
  • --file: Use the service file from this location to start the service.

参考

公式サイトを参照すればすぐわかります。

6
7
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
6
7