用 bootout 与 bootstrap 重启用户 LaunchAgent
通过 launchd 干净地卸载并重新加载卡死或异常的用户代理,而不是直接杀掉进程。
先运行 launchctl bootout gui/$UID/<标签>,再运行 launchctl bootstrap gui/$UID ~/Library/LaunchAgents/<标签>.plist,即可停止该代理并按 plist 重新启动。
01命令
命令
$ launchctl bootout gui/$UID/<label> && launchctl bootstrap gui/$UID ~/Library/LaunchAgents/<label>.plist02作用说明
bootout 会把服务从用户 gui 域中移除,停止其进程并清掉 launchd 在内存中的状态;bootstrap 则重新读取磁盘上的 plist 并启动服务,效果如同刚登录时一样。旧语法 launchctl unload / launchctl load 是它们的等价形式,Apple 现已标记为遗留命令,但在当前 macOS 上仍然可用。
03风险
!注意: 如果该代理当前未加载,bootout 会报错——这是正常现象,可以直接执行 bootstrap。若服务由 brew services 管理,请用 brew 来重启,以免记录不同步。
04撤销
撤销
$ launchctl bootout gui/$UID/<label>05来源
- launchctl — interact with launchd (macOS)依据: The page documents bootout domain/service-target as "Remove domain/service (equivalent to unload in the legacy syntax)", shows the gui/uid/[service-name] specifier form, and gives examples pairing bootout with the new syntax against legacy unload.
- launchctl(1) — macOS man page依据: The man page documents bootstrap gui/uid <plist-path> to load a service into the user's gui domain and bootout gui/uid/service-label to remove it, noting these replace the legacy load/unload subcommands.
最后验证: 2026-09-19 · 分类: 系统与设置