这个问题可能没有答案!似乎launchctl list 中的所有内容都不会有 plist 文件。
如前所述,launchctl dumpstate 将为您提供大量信息,包括 plist 路径(如果存在)。
您可以运行此命令以大致查看正在运行的所有内容及其 plist 路径的列表。
launchctl dumpstate | grep -A4 " = {" | grep -B 3 -A 3 -E "active count = [1-9]"
(虽然这似乎也包括其他运行的程序不是由 launchd 管理的守护进程?)
代理/守护程序将在其标识符下方有一个路径字段。通常,路径指向Reed's answer 描述的标准 5 个位置中的 plist 文件。但是,它不一定是。例如,Steam 从非标准位置加载 launchctl 服务。
➜ launchctl dumpstate | grep -A4 " = {" | grep -B 3 -A 3 -E "active count = [1-9]" | grep valve
com.valvesoftware.steam.ipctool = {
path = /Users/chris/Library/Application Support/Steam/com.valvesoftware.steam.ipctool.plist
幸运的是,这种做法并不太流行,因此搜索标准位置通常就足够了。
但这还不是最棘手的事情。我不知道具体细节,但似乎launchctl 服务可以在没有相应的 plist 文件的情况下加载。例如,这就是 dumpstate 对 1Password 助手守护进程所说的内容。
➜ launchctl dumpstate | grep -A4 " = {" | grep -B 3 -A 3 -E "active count = [1-9]" | grep -A4 "onepassword7-helper = {"
2BUA8C4S2C.com.agilebits.onepassword7-helper = {
active count = 5
path = (submitted by smd.1154)
state = running
我不知道“由 smd 提交”的真正含义,但归结为即使我在 launchctl list 中看到了帮助程序,文件系统上也可能没有任何 plist。因为这个我不知道如何launchctl unload这个服务因为卸载需要一个plist路径!而且由于这个进程是由launchd 管理的,即使我pkill -9 onepassword7-helper,launchd 看到进程停止并重新启动它。
(幸运的是,对于这个特定的 1Password 示例,如果您在单击退出 1Password 时按住 ^ 和 ⌥,则会出现一个特殊的“完全使用 1Password”选项)