Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/macos/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Macos 如何使用launchtl启动守护程序?_Macos_Launchctl - Fatal编程技术网

Macos 如何使用launchtl启动守护程序?

Macos 如何使用launchtl启动守护程序?,macos,launchctl,Macos,Launchctl,我正在尝试使用下面的命令启动一个守护程序,并运行到路径的所有权/权限不正确的地方,如何修复此问题并启动并确保它正在运行 teambot47:wifi_bas_server username$ sudo launchctl load -w /Users/username/wifi-automation/technology_version_report/com.company.internal.technologyreport.daily.plist /Users/username/wifi-a

我正在尝试使用下面的命令启动一个守护程序,并运行到
路径的所有权/权限不正确的地方
,如何修复此问题并启动并确保它正在运行

teambot47:wifi_bas_server username$ sudo launchctl load -w /Users/username/wifi-automation/technology_version_report/com.company.internal.technologyreport.daily.plist 
/Users/username/wifi-automation/technology_version_report/com.company.internal.technologyreport.daily.plist: Path had bad ownership/permissions
以下是plist上的权限

teambot47:wifi_bas_server username$ ls -lrta /Users/username/wifi-automation/technology_version_report/com.company.internal.technologyreport.daily.plist
-rwxrwxrwx  1 username  staff  811 May 17 15:38 /Users/username/wifi-automation/technology_version_report/com.company.internal.technologyreport.daily.plist

我不确定确切的要求,但守护程序配置文件至少需要归root所有,我认为它们不能对任何其他用户或组具有写访问权限;路径中的目录也可能有限制。一般来说,守护程序文件应该安装在/Library/LaunchDaemons中,而不是安装在用户的主目录中。@GordonDavisson-当我运行
launchctl list时| grep com.company.internal.firmwarereport.daily
我得到的输出是
-1 com.apple.internal.firmwarereport.daily
,这意味着什么?这意味着它已经加载了吗?我怎么知道它是否加载了呢?
launchctl list
(不带
sudo
)列出了代理(当用户登录时在用户帐户下运行),而不是守护进程(通常以root用户身份运行,与登录用户无关)
sudo launchctl load
尝试将其作为守护进程加载。你想把它当作什么来运行?此外,该输出似乎表明它是作为代理加载的,试图运行,但退出时出现错误状态(“1”)。为了澄清,我有一个plist,我想将其作为守护进程加载,并检查其状态是否正在运行…如何做?最简单、最可靠的方法:首先作为代理卸载它(
launchctl unload-w/path/to/file.plist
--no
sudo
),将其移动到/Library/LaunchDaemons,将所有者和组更改为root:wheel,将权限更改为644,然后重新启动。