crontab to wake osx from sleep

cron doesn't execute while the computer is asleep, so there's no way for you to have a crontab entry to wake the computer. That said you can schedule the computer to wake just a minute or two before your cron task in Preferences >> Energy Saver >> Schedule.

It's also worth pointing out that since Tiger, Apple has moved most scheduled jobs from cron and scripts like init.rc to the launchd process. It provides more detailed (but cumbersome, I think) means of control (through several plist files). It will also automatically run tasks missed because the computer was sleeping when it awakens. Take a look at Apple's Scheduling Timed Jobs page.


Another way to schedule waking up from sleep is to use pmset:

sudo pmset repeat wakeorpoweron MTWRFSU 03:45:00

launchd cannot wake a computer from sleep, but it does run jobs scheduled during sleep after waking up. If others search for how to do that, you can for example save this plist as ~/Library/LaunchAgents/some.label.plist:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
  <key>Label</key>
  <string>some.label</string>
  <key>ProgramArguments</key>
  <array>
    <string>say</string>
    <string>a</string>
  </array>
  <key>StartCalendarInterval</key>
  <dict>
    <key>Hour</key>
    <integer>23</integer>
    <key>Minute</key>
    <integer>59</integer>
  </dict>
</dict>
</plist>

Then run launchctl load ~/Library/LaunchAgents/some.label.plist.


You can schedule your Macintosh to wake up in the Energy Saver preference panel. See the Schedule button.


You might want to look into Anacron

Anacron runs the periodic daily, weekly and monthly tasks on your Mac even if the machine (a laptop, for example) spends much of its time asleep or switched-off. Anacron silently checks when you reboot and every sixty minutes while the computer is running to see if the various periodic scripts are overdue, and runs them if necessary. The advantage of Anacron over many other solutions to this issue is that it runs as a proper Unix background process, requires no user intervention, and uses the regular periodic scripts.

Another applicaiton that might do the trick is Awaken