2

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).

2
  • The short answer is no. If you want your "task" to only run at prescribed times then consider using cron.
    – fd0
    Commented Sep 12, 2019 at 12:46
  • I had a similar problem with launchd causing simultaneous parallel executions of a single task, resulting in output to a single file with duplicate interleaved lines. This was NOT caused by a missed interval, but by a single StartCalendarInterval one minutes after the computer woke from sleep by the System Preferences Energy Saver Schedule. I also had to resort to 'cron' get a single output.
    – Dickster
    Commented Oct 2, 2019 at 17:39

1 Answer 1

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.

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