LAUNCHCTL
launchctl #
简单解释,launchd是一套统一的开源服务管理框架,它用于启动、停止以及管理后台程序、应用程序、进程和脚本。launchd是macOS第一个启动的进程,该进程的PID为1,整个系统的其他进程都是它创建的。
1).
当launchd启动后,它会扫描/System/Library/LaunchDaemons
和/Library/LaunchDaemons
中的plist文件并加载他们;2).
当输入密码登录系统后,launchd会扫描/System/Library/LaunchdAgents
、/Library/LaunchAgents
、~/Library/LaunchAgents
这三个目录中的plist文件并加载它们。每个plist文件都是一个任务,加载不代表立即运行,只有设置了RunAtLoad为true或keepAlive为true时,才会加载并同时启动这些任务。name ope 帮助 launchctl help
列出所有由launchd管理的进程 launchctl list
加载 launchctl load ~/Library/LaunchAgents/docs.wtfu.site.plist
卸载 launchctl unload ~/Library/LaunchAgents/docs.wtfu.site.plist
启动 (luanchctl start <Label>
)launchctl start dos.wtfu.site
关闭 launchctl stop dos.wtfu.site
restart #
摘自 How to start/stop/restart launchd services from the command line?
Just in case if you are looking for launchctl reload, you can define shell function in your ~/.bashrc/.zshrc as I did:
Command execution looks like ->lctl reload <your-plist-name>.plist
plist #
path:
~/Library/LaunchAgents/docs.wtfu.site.plist
path:
~/Library/LaunchAgents/tech.wtfu.site.plist
path:
~/Library/LaunchAgents/frp.wtfu.site.plist
path:
~/Library/LaunchAgents/jetbrains.vmoptions.plist
reload #
Reference #