10

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?

  • It appears that my KeepAlive definition was implying RunAtLoad, and even overriding my attempt to set RunAtLoad to false. Not sure why this is the case, but taking out the KeepAlive block seems to have fixed the problem. – user76493 Apr 23 '14 at 12:40
10

You likely have an interaction between the SuccessfulExit and RunAtLoad keys. The launchd plist manual page mentions an inversion takes place if RunAtLoad is set :

SuccessfulExit

If true, the job will be restarted as long as the program exits and with an exit status of zero.

If false, the job will be restarted in the inverse condition. This key implies that "RunAtLoad" is set to true, since the job needs to run at least once before we can get an exit status.

Others have struggled with this behaviour, see launchd ignores RunAtLoad=false.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .