Is it possible to prevent launchd running a missing task on wake? [duplicate]

I have a launchd task configured to run once an hour using the StartCalendarInterval key to set specific times at which the task will run.

However, the default behaviour of this is that, when an interval is missed (i.e- computer was asleep) the task will immediately run at the next available opportunity (i.e- on wake).

Is it possible to disable this behaviour in my plist file?

I haven't found any obvious key(s) for controlling this, and the only other thing I can think of is to check the current time in the task itself, but this means duplication of timing behaviour (set the time in the plist, and then check it in the task itself).


Solution 1:

shell script wrapper

launchd has no built-in method for limiting tasks that missed their start time. Your idea to use a shell script wrapper to evaluate the desired time and actual time is a reasonable approach.

For Power Manager, we provided a drift duration for exactly this purpose. Drift lets the user state how long after a missed trigger time the event is permitted to run.