I read that if the computer is sleeping when a launchd event is to occur, then launchd will run the event when the computer wakes up.

My question is in regards to a computer that is shut down. If the machine is powered off when a launchd event is to occur, is launchd supposed to run it at the next power-on?

I ask because I have created an event (agent?) to run at 09:45am every day. But often the machine is powered off at that time. I am not seeing the output of the event (an email being sent) after I power on the computer. So I am trying to narrow down if this is behavior by design or have I messed something up.


It's limited to jobs that were scheduled during sleep (not when shut down) and by a StartCalendarInterval parameter (not StartInterval).

Daemons and Services Programming Guide: Scheduling Timed Jobs

If you schedule a launchd job by setting the StartCalendarInterval key and the computer is asleep when the job should have run, your job will run when the computer wakes up. However, if the machine is off when the job should have run, the job does not execute until the next designated time occurs.

All other launchd jobs are skipped when the computer is turned off or asleep; they will not run until the next designated time occurs.


It might be that the event fails because it is run before Internet connectivity is fully established.

Here is some info from the article Schedule jobs using launchd :

If your computer sleeps often, it will be asleep when jobs should run, which means it will run them right when it wakes up, possibly before it connects to the internet. I have experimented with KeepAlive and NetworkState to get a job to repeat itself until there is a network connection. You could also use SuccessfulExit write the script so that it only returns a nonzero code to mean “run again in 10 seconds.” Either method would have the script running (and presumably failing) every 10 seconds when you have no internet connection. A better idea would be to just sleep 5 seconds at the beginning of your script. Or you could double the run frequency and hope for the best.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.