launchd 似乎忽略了优胜美地的 StartCalendarInterval

Min*_*Liu 9 launchd homebrew launchctl macos

我尝试使用launchd按时更新Homebrew。我的 plist 文件显示在这里:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
  <key>Label</key>
  <string>ms.liu.homebrew.update</string>
  <key>UserName</key>
  <string>LiuMS</string>
  <key>ProcessType</key>
  <string>Background</string>
  <key>EnvironmentVariables</key>
  <key>ProgramArguments</key>
  <array>
    <string>/usr/local/bin/brew</string>
    <string>update</string>
  </array>
  <key>StartCalendarInterval</key>
  <dict>
    <key>Hour</key>
    <integer>20</integer>
    <key>Minute</key>
    <integer>0</integer>
  </dict>
  <key>StandardOutPath</key>
  <string>/usr/local/logs/ms.liu.homebrew.update.out</string>
  <key>StandardErrorPath</key>
  <string>/usr/local/logs/ms.liu.homebrew.update.err</string>
</dict>
</plist>
Run Code Online (Sandbox Code Playgroud)

它确实以某种方式工作:我可以launchctl start ms.liu.homebrew.update手动执行以更新我的 Homebrew。但是,launchd 不会定期执行此服务:对 stdout 重定向到的文件的最后更改是两天前。

我试图获取有关此服务的信息,但一无所获:

> launchctl print user/%MyPID%/ms.liu.homebrew.update`` 
Could not find service "ms.liu.homebrew.update" in domain for uid: %MyPID%
Run Code Online (Sandbox Code Playgroud)

看起来我还没有成功加载我的服务。如何?我使用过,launchctl load但似乎已被弃用。手册页推荐引导程序:

> launchctl bootstrap user/%MyPID% %Path-to-plist%
> %Path-to-plist%: Service cannot load in requested session
Run Code Online (Sandbox Code Playgroud)

我该怎么办?如何正确使用launchctl bootstraplaunchctl print

我在配备 Retina 显示屏的 MacBookPro 上运行 OS X Yosemite GM Candidate 1(2013 年)。

小智 2

我\xe2\x80\x99m才刚刚开始解决这个问题,所以这个答案是暂定的\xe2\x80\x93\xc2\xa0但我希望\xe2\x80\x99比没有答案更有帮助。(如果我有足够的代表,我会把它留下作为评论。)

\n\n

这个 plist 在你的~/Library/LaunchAgents目录中吗?看来这些是引导到您的gui域中的,而不是您的user域中的。所以你可以这样做:

\n\n
launchctl print gui/%UID%/ms.liu.homebrew.update\n
Run Code Online (Sandbox Code Playgroud)\n\n

它应该有效。(可以?)

\n\n

大概您可以\xe2\x80\x99t 将其引导到域中的原因user是它\xe2\x80\x99s 已经引导到gui

\n