Reputation: 8083
I am trying to use launchd to run a python script every 10 minutes. This is easy with cron, but I have been trying for several hours to understand how to operate launchd and I have been unsuccessful. I am using a version of python located in /Users/turtle/bin/
. Here is what my launchd file (com.foobar
) looks like:
<?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.foobar</string>
<key>ProgramArguments</key>
<array>
<string>/Users/turtle/bin/python</string>
<string>/Users/turtle/code/baz.py</string>
</array>
<key>StartCalendarInterval</key>
<dict>
<key>Minute</key>
<integer>10</integer>
</dict>
</dict>
</plist>
When I run:
launchctl load /Library/LaunchAgents/com.foobar
I get:
launchctl: Couldn't stat("/Library/LaunchAgents/com.foobar"): No such file or directory nothing found to load
Can anyone help me? Thanks for your time.
Upvotes: 1
Views: 2039
Reputation: 7191
StartCalendarInterval with the key Minute : the script run at the 10th minutes of every hour.
You must use StartInterval : job to be started every N seconds
<key>StartInterval</key>
<integer>600</integer>
Upvotes: 1