![](/img/trans.png)
[英]Getting a status 78 launchctl when trying to run a python script with launchd
[英]Trying to run Python script with launchctl / launchd but it won't load. Exit status is 2
我正在尝试在macOS上每5分钟通过launchctl运行一个简单的Python脚本。 我已经按照以下步骤创建了播放列表:
<?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>com.myscript</string>
<key>ProgramArguments</key>
<array>
<string>/Users/me/Documents/myscript.py</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>StartInterval</key>
<integer>300</integer>
</dict>
</plist>
但是,该脚本永远不会运行。 我已经加载和卸载了多次。 执行命令
/Users/me/Documents/myscript.py
工作正常,因为我在Python脚本的开头添加了“#!/ usr / bin / env python”。 如果运行launchctl -l,则会看到:
- 2 com.myscript
我不确定退出状态为2意味着什么。 有人可以帮忙吗?
我通过使用cron(以前也不起作用)将问题脚本移到我的Home文件夹的根目录而不是Documents文件夹的目录中来工作。 我认为问题是macOS Catalina对访问“文档”或“桌面”文件夹中的文件的新限制。 将脚本移到其他地方似乎可以解决它。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.