How to I stop a launchd script from running on wake

by pheon   Last Updated December 06, 2018 15:12 PM

I have a simple launchd script that plays a sound every 30 minutes. It doesn't run if my machine is asleep, but does run the last event missed when the machine wakes. I think this is the expected behavior. My question is, how do I stop this happening. If I missed the half-hour event, I don't want it to be run at 20 minutes past the hour.

Here's the core of my script. It calls a Python script. I tried to put a block in the python script to check that I am within a few minutes of each 30 minutes, but that doesn't seem to work on wake. (Is it missing the system clock somehow?)

<key>ProgramArguments</key>
<array>
    <string>/usr/local/bin/python3</string>
    <string>/Users/pheon/Documents/playsound.py</string>
</array>

<key>StartCalendarInterval</key>
<array>
    <dict>
        <key>Minute</key>
        <integer>0</integer>
    <dict>
        <key>Minute</key>
        <integer>30</integer>
    </dict>
</array>


Related Questions


Caffeinate in launchd doesn't keep system awake?

Updated February 22, 2016 03:05 AM



Specify port number for Wake up on network access

Updated September 24, 2018 10:12 AM