Im trying to run a python script using launchd on OS X. When I run it from the terminal using the following commands, it works:
$ /Library/Frameworks/Python.framework/Versions/3.4/bin/python3.4 /Users/me/path/to/script.py
Here is my launchd plist file that has those same commands under the ProgramArguments key, but it doesn't work.
<?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>net.me.my-script</string>
<key>ProgramArguments</key>
<array>
<string>/Library/Frameworks/Python.framework/Versions/3.4/bin/python3.4</string>
<string>/Users/me/path/to/script.py</string>
</array>
<key>StartInterval</key>
<integer>86400</integer>
</dict>
</plist>
The launchd initially didnt work, so I tried running it in the terminal manually, and I got an error and realized that I needed to refer to files I was reading and writing to in the python script with their full path, so I fixed that. That made the script run in terminal but it didn't fix the problem in launchd (yes, I've unloaded and loaded it multiple times).
I ran launchctl list and found a 1 exit code listed next to my plist, then I checked /var/log/system.log and found the error message Service exited with abnormal code: 1 but that's all the error messages I can find.
Based on 'last modified' dates and stuff from finder, it seems like it opens an xml file in the python script, but it doesn't write anything to it. It also doesn't seem to open a json file in the script.
Again, all this stuff works just fine run manually in the terminal, so I'm thinking it has to be a plist or launchd issue.
Service exited with abnormal code: 1error; what does the python script actually do? You should see other events in Console.app right around the same time that might be related.