我跑这每一分钟来调试,并保持与com.apple.xpc.launchd[1] (com.me.DesktopChanger[16390]): Service exited with abnormal code: 2
简单的launchd运行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>
<!-- The label should be the same as the filename without the extension -->
<string>com.me.DesktopChanger</string>
<!-- Specify how to run your program here -->
<key>ProgramArguments</key>
<array>
<string>/usr/bin/python</string>
<string>~/Library/Application\ Support/DesktopChanger/DesktopChanger.py</string>
</array>
<key>StartInterval</key>
<integer>60</integer>
</dict>
</plist>
返回的launchd脚本称为:com.me.DesktopChanger.plist
的Python脚本位于:/Users/Tom/Library/Application Support/DesktopChanger/DesktopChanger.py
和which python
回报:/usr/bin/python
飞奔摹ls -l
也返回:
[email protected] 1 Tom staff 623 6 Feb 13:40 com.me.DesktopChanger.plist
与ls -l
显示了python脚本:
[email protected] 1 Tom staff 672 2 Dec 14:24 DesktopChanger.py
我尝试添加错误处理并尝试使用相对路径。当我尝试卸载Launchd脚本时发现错误消息,说'launchd无法直接运行' – Tom
您是否尝试使用脚本的绝对路径?控制台中的标准错误输出是什么?你尝试安装LaunchControl并使用它进行调试吗?这对我帮助很大。 – wij
我用LaunchControl试过它,它声明它运行“Ok”,但python脚本似乎没有执行 – Tom