macOS服务管理

参考: https://www.jianshu.com/p/d6f09bc4142e

launchctl服务管理

launchctl类似于Linux的systemd


使用launchctl 添加启动服务

#添加启动服务
sudo launchctl load /Library/LaunchDaemons/com.zerotier.one.plist

#卸载启动服务
sudo launchctl unload /Library/LaunchDaemons/com.zerotier.one.plist


# 查看所有的 plist 服务
launchctl list

# 禁用服务
launchctl disable /Library/LaunchDaemons/com.simonkuang.macos.coredns.plist

# 启用服务
launchctl disable /Library/LaunchDaemons/com.simonkuang.macos.coredns.plist

# 杀死进程(不优雅地杀,直接杀进程)并重启服务。对一些停止响应的服务有效。
launchctl kickstart -k /Library/LaunchDaemons/com.simonkuang.macos.coredns.plist

# 在不修改 Disabled 配置的前提下启动服务
launchctl start /Library/LaunchDaemons/com.simonkuang.macos.coredns.plist

# 在不修改 Disabled 配置的前提下停止服务
launchctl stop /Library/LaunchDaemons/com.simonkuang.macos.coredns.plist

使用brew管理服务


# 启动服务
brew services start zerotier # 启动zerotier服务

# 停止服务
brew services stop zerotier

猜你喜欢

转载自blog.csdn.net/omaidb/article/details/123162575