2
1
I have a crontab job scheduled to run every hour. I like to sleep and I also enjoy giving my macbook the same privileges. Unfortunately, cron does not execute when the system is asleep. Is there a way to do the following:
Every hour,
- Check if computer is already asleep.
- If asleep, wake up computer.
- Wait for crontab job to finish.
- Go back to sleep if computer was previously asleep.
I understand I can use pmset to schedule wake/sleep for every hour, but I want to selectively put the computer back to sleep (conditional on whether or not it was asleep before the wake routine started running).
Unless I'm misunderstanding something, it seems that the
pmset
command given won't actually wake the machine hourly:pmset -g sched
shows that only one repeating event gets scheduled (each iteration of the loop replaces the last).pmset relative wake 3600
may be a viable alternative to actually waking hourly (though I haven't yet tried this myself). – mrkj – 2015-11-29T18:43:06.837