I'd like to run a python script every minute using launchd. My plist file looks like this:
<?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.turtle.script.plist</string>
<key>ProgramArguments</key>
<array>
<string>/usr/bin/python</string>
<string>/Users/turtle/Desktop/turtle.py</string>
<string>/Users/turtle/Desktop/data/data.txt</string>
</array>
<key>StartInterval</key>
<integer>60</integer>
</dict>
</plist>
This plist file looks good, as I get the following:
plutil -lint com.turtle.script.plist
com.turtle.script.plist: OK
The script works when I run it from the command line:
/usr/bin/python /Users/turtle/Desktop/turtle.py /Users/turtle/Desktop/data/data.txt
I load this plist via:
launchctl load -w -F com.turtle.script.plist
I've alse tried:
sudo launchctl load -w -F com.turtle.script.plist
I load this job and the python script should write out a file to disk. However no file is ever produced. I examine the job with:
sudo launchctl list | grep com.turtle.script.plist
The output is:
- 1 com.turtle.script.plist
Can anyone help trouble-shoot the problem?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…