Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

I have systems running Mac OS X 10.5.8 and 10.6.8 that I would like to schedule some cron jobs for with the Cronnix GUI application.

I prefer those computers be asleep until the scheduled jobs start. I know the Energy Saver System Preferences pane lets me schedule daily wake up times for the computer, but my cron jobs run at different times in the day.

Is there a way to set up more than one wake up time per day on these Macs? I prefer a GUI based approach but any ideas you have would be great, thanks!

share|improve this question

4 Answers 4

up vote 11 down vote accepted

Sorry, I only know command-line tools to do the job.

You can use pmset for that (like in pmset schedule wake "02/12/2012 12:42:00").

More explanations here and, of course, man pmset.

Setting Multiple "Power On" & Power Off" Events

Currently, it appears that pmset will NOT allow you to set more than one pair of "power on" & "power off" events when using a repeating schedule.

For example...

# pmset repeat shutdown MTWRFSU 02:00:00 wakeorpoweron MTWRFSU 06:45:00

The above command would set a repeating schedule that would shutdown the Mac nightly at 2 AM in the morning and startup daily at 6:45 AM.

But, if you want to set multiple "power on" & "power off" events, you could specify a specific date/time and with a little scripting you could setup a schedule for a month.

# pmset schedule wakeorpoweron "06/07/2007 07:00:00"
# pmset schedule shutdown "06/07/2007 22:00:00"
# pmset schedule wakeorpoweron "06/07/2007 00:00:00"
# pmset schedule shutdown "06/07/2007 01:00:00"
share|improve this answer

This article, How to Power On Your Mac at a Specific Date and Time, shows how to schedule your Mac to power on using Energy Saver, pmset, and Power Manager.

The most capable method is with Power Manager; it can schedule the multiple power on and wake up events you need using the Graphical User Interface (GUI).

Power Manager supports Mac OS X 10.6 and later, but the previous version is still available and supports Mac OS X 10.4 - 10.7 for PPC and Intel.

Disclosure: I work for the company who makes Power Manager.

enter image description here

share|improve this answer

You can use cron to change the wake up time using pmset. E.g., say you want to run script1 at 1 am and script2 at 3 am. In root's crontab:

0 1 * * * /path/to/script1
0 1 * * * pmset repeat shutdown MTWRFSU 01:01:00 wakeorpoweron MTWRFSU 02:59:00

0 3 * * * /path/to/script2
0 3 * * * pmset repeat shutdown MTWRFSU 03:01:00 wakeorpoweron MTWRFSU 00:59:00

When script1 is run, cron runs pmset to shutdown in 1 min and wake up when it is time to run script2. Likewise when script2 is run, it sets back up for script1.

Chaining your cron jobs this way would be equivalent to using multiple wake up times.

share|improve this answer
    
How does one edit the root's crontab? –  martineau Jan 29 '14 at 18:04
2  
@martineau sudo crontab –  user66309 Feb 1 '14 at 7:34

Chaining CRON jobs to power-on like user66309 suggested would be the best solution. But to ensure that the first CRON job actually runs, you need to add an @reboot CRON job to schedule the first wakeorpoweron event.

# the first wake or power on event is scheduled just before midnight
@reboot pmset repeat wakeorpoweron MTWRFSU 23:59:00
# schedule script1 for 1 minute past midnight
# keep computer awake as long as script1 is running
1 0 * * * caffeinate -i path/to/script1
# wake or power on computer a few minutes before script2 is scheduled
1 0 * * * pmset repeat wakeorpoweron MTWRFSU 11:59:00
# keep computer awake as long as script2 is running
1 12 * * * caffeinate -i path/to/script2
# wake or power on computer a few minutes before script1 is scheduled
1 12 * * * pmset repeat wakeorpoweron MTWRFSU 23:59:00

As an additional suggestion, I wouldn't schedule a shutdown or sleep event. Instead I'd run the script with caffeinate -i. This way the computer stays awake for as long as the script needs, and afterwards the system settings for sleeping take effect. This way your computer won't shut down while your working on it.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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