相关疑难解决方法(0)

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

我尝试使用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 …
Run Code Online (Sandbox Code Playgroud)

launchd homebrew launchctl macos

9
推荐指数
1
解决办法
1549
查看次数

launchd 是否应该接收“错过的”事件?

我读到如果在发生 launchd 事件时计算机处于睡眠状态,则 launchd 将在计算机唤醒时运行该事件。

我的问题是关于已关闭的计算机。如果在发生 launchd 事件时机器断电,launchd 是否应该在下一次开机时运行它?

我问是因为我创建了一个事件(代理?),每天上午 09:45 运行。但通常在那个时候机器是断电的。打开计算机电源后,我没有看到事件的输出(正在发送电子邮件)。所以我试图缩小范围,如果这是设计行为还是我搞砸了什么。

launchd osx-mountain-lion macos

7
推荐指数
1
解决办法
2601
查看次数

标签 统计

launchd ×2

macos ×2

homebrew ×1

launchctl ×1

osx-mountain-lion ×1