【Macで開発】Linuxのchkconfig的なlaunchctlの使い方

f:id:kitahashi-ryoichi:20151117004102j:plain

Mac環境で自動起動させる方法

Linuxだと便利な「chkconfig」コマンドでやりますよね。

chkconfig mysql on

 

Macだとhomebrewがコマンドを教えてくれます

brew info mysql

To have launched start mysql at login:
  ln -sfv /usr/local/opt/mysql/*.plist ~/Library/LaunchAgents
Then to load mysql now:
  launchctl load ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist
Or, if you don't want/need launchctl, you can just run:
  mysql.server start

 

言われたとおりに2つのコマンドを実行すると「chkconfig mysql on」と同じように自動起動設定ができます。

ln -sfv /usr/local/opt/mysql/*.plist ~/Library/LaunchAgents
launchctl load ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist

 

まとめ

homebrewでインストールしたらbrew infoするとハッピーになれる。自動起動設定を覚えるのめんどくさい。