gpt4 book ai didi

macos - launchd:在 macOS 上控制服务的 bootstrap/bootout 语义上的混淆

转载 作者:行者123 更新时间:2023-12-05 03:59:13 34 4
gpt4 key购买 nike

我已阅读以下有关 launchd 的手册页:launchctllaunchdlaunchd.plist

但是,这些手册页中并没有真正说明 launchctl boostraplaunchctl bootout(子)命令的实际作用(见下文)。是从他们的名字推断出来的吗?

此外,我无法在手册页中找到有关服务(代理/守护程序)运行的用户/组的信息。但是,launchd.plist 提到了 UserName/GroupName 用于控制系统域的用户/组。那么,/Library/LaunchAgents~/Library/LaunchAgents 中的每用户服务以什么用户运行?

最后,我希望我需要bootstrap/load 我的daemon 的.plist,但是在将.plist 放入/Library/LaunchAgents/Library/LaunchDaemons,它在系统启动时自动加载(运行)。的确,RunAtLoad=true,但是如果服务仍然运行,bootstrap 的目的是什么?

man launchctl:

 bootstrap | bootout domain-target [service-path service-path2 ...] | service-target
Bootstraps or removes domains and services. When service arguments are present, bootstraps and correspondingly removes their definitions into the domain. Services may be specified as a series of
paths or a service identifier. Paths may point to XPC service bundles, launchd.plist(5) s, or a directories containing a collection of either. If there were one or more errors while bootstrapping or
removing a collection of services, the problematic paths will be printed with the errors that occurred.

If no paths or service target are specified, these commands can either bootstrap or remove a domain specified as a domain target. Some domains will implicitly bootstrap pre-defined paths as part of
their creation.

最佳答案

bootstrapbootout 可用于加载和卸载服务, 无需重新启动或登录和退出。如果您需要暂时停止服务以执行某些任务,然后在不需要重新启动系统的情况下再次启动它,它们会很有用。

/Library/LaunchDaemons 默认以 root 身份运行。您可以使用 UserNameGroupName 键来控制守护进程的配置。

/Library/LaunchAgents 作为当前登录的用户运行(这些为每个用户运行)。

~/Library/LaunchAgents 作为该特定用户运行。

进一步阅读:

关于macos - launchd:在 macOS 上控制服务的 bootstrap/bootout 语义上的混淆,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57412590/

34 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com