运行 Python launchctl 脚本 - 错误 127
Run Python script on launchctl - error 127
所以我在 osx 上尝试通过 LaunchAgents 运行 一个脚本,但我一直让服务退出并出现异常代码:127 错误。
当我 运行 终端中的脚本时,一切正常(它只是一个用于打开浏览器选项卡的测试脚本)。我已经验证了 .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>local.restart</string>
<key>Program</key>
<string>/Users/flp/PythonScripts/run.py</string>
<key>RunAtLoad</key>
<true/>
<key>StartInterval</key>
<integer>60</integer>
</dict>
</plist>
这是脚本:
#! /usr/bin/env python3
import webbrowser
a_website = "https://www.abola.pt"
# Open url in a new window of the default browser, if possible
webbrowser.open_new(a_website)
这是来自 launchctl 的日志:
com.apple.xpc.launchd[1] (local.restart[3080]): Service exited with abnormal code: 127
我是不是做错了什么?
问题出在 shebang 中。编译器路径不正确,修复它并且它按预期工作。
所以我在 osx 上尝试通过 LaunchAgents 运行 一个脚本,但我一直让服务退出并出现异常代码:127 错误。
当我 运行 终端中的脚本时,一切正常(它只是一个用于打开浏览器选项卡的测试脚本)。我已经验证了 .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>local.restart</string>
<key>Program</key>
<string>/Users/flp/PythonScripts/run.py</string>
<key>RunAtLoad</key>
<true/>
<key>StartInterval</key>
<integer>60</integer>
</dict>
</plist>
这是脚本:
#! /usr/bin/env python3
import webbrowser
a_website = "https://www.abola.pt"
# Open url in a new window of the default browser, if possible
webbrowser.open_new(a_website)
这是来自 launchctl 的日志:
com.apple.xpc.launchd[1] (local.restart[3080]): Service exited with abnormal code: 127
我是不是做错了什么?
问题出在 shebang 中。编译器路径不正确,修复它并且它按预期工作。