I have an old iMac running macOS Catalina. I've scheduled 2 CRON jobs, one running in the morning (say, 8am) and one running in the afternoon (say, 5pm). The CRON jobs run a few R scripts, in case that matters.

Given that CRON jobs won't execute if the machine is sleeping, I'm wondering what's the best way to make sure both jobs are executed. Right now I've scheduled for the Mac to "wake up" in the morning and "Shut down" in the evening, but unless I prevent it going to sleep completely, the afternoon job isn't executed.

Two potential solutions came to mind: first, setting up a different user profile with a different schedule - but that didn't work, since there's only one schedule per machine. Second, "Power Nap", but that doesn't seem to execute the job either, or at least not consistently. Now, short of either never allowing sleep or building a robot to move the mouse in the afternoon and wake up the machine, I'm running out of options...

Any better ideas?

Thanks, Philipp


1 Answer 1


Apple intents to phase out cron (but this is going on for such a long time that I forgot when they first announced this :-)). Nevertheless, using launchd instead would solve your problem quite easily.

From man launchd.plist:

StartCalendarInterval <dictionary of integers or array of dictionaries of integers>

This optional key causes the job to be started every calendar interval as specified. 
Missing arguments are considered to be wildcard. The semantics are similar to crontab(5)
in how firing dates are specified. Multiple dictionaries may be specified in an array
to schedule multiple calendar intervals.

Unlike cron which skips job invocations when the computer is asleep, launchd will start
the job the next time the computer wakes up.  If multiple intervals transpire before the
computer is woken, those events will be coalesced into one event upon wake from sleep.

This answer on StackOverflow has a basic launchd.plist template for simple cronjobs.

You must log in to answer this question.

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