I have a launchd plist file that I use to run a program at a selected time every day. It works, but it also runs the program whenever I boot the computer or unload and reload the job using the GUI program LaunchControl—even though I have the RunAtLoad
key set to false?
The complete plist file is below; it is located in /Library/LaunchAgents/
:
<?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>RunAtLoad</key>
<false/>
<key>KeepAlive</key>
<dict>
<key>SuccessfulExit</key>
<false/>
</dict>
<key>Label</key>
<string>com.adbot.plist</string>
<key>LowPriorityIO</key>
<true/>
<key>Program</key>
<string>/Users/wcm1/programming/ricedh/adbot/adbot.py</string>
<key>StandardErrorPath</key>
<string>/tmp/com.adbot.plist.err</string>
<key>StandardOutPath</key>
<string>/tmp/com.adbot.plist.out</string>
<key>StartCalendarInterval</key>
<array>
<dict>
<key>Hour</key>
<integer>10</integer>
<key>Minute</key>
<integer>30</integer>
</dict>
</array>
</dict>
</plist>
Thoughts?
Best Answer
You likely have an interaction between the
SuccessfulExit
andRunAtLoad
keys. The launchd plist manual page mentions an inversion takes place ifRunAtLoad
is set :Others have struggled with this behaviour, see launchd ignores RunAtLoad=false.