Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'Set different startup times for different days' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Set different startup times for different days
Authored by: dtrevas on Jan 01, '06 12:32:57AM
For those interested in really getting control over powering on and off or waking and sleeping, read the manual page for pmset. (Go to Terminal and type man pmset) Instead of focusing on the "pmset repeat" option, consider the "pmset schedule" option. With "pmset schedule" you can set as many wake, sleep, shutdown, poweron and wakeorpoweron events as you like. You do have to be root to do it (I use "sudo") and maybe one day someone will be nice enough to make a GUI app to keep you from having to muck with the command-line. Here's how I'd get my computer to come on at 2:00 pm on Jan 2, 2006 and sleep at 3:10 pm on the same day:
sudo pmset schedule wakeorpoweron "01/02/06 14:00:00"
password:******
sudo pmset schedule sleep "01/02/06 15:10:00"

To verify the scheduling, type:

pmset -g sched

And get the following results:

Scheduled power events:
 [0]  wakeorpoweron at 01/02/06 14:00:00
 [1]  wakeorpoweron at 01/02/06 14:00:00
 [2]  sleep at 01/02/06 15:10:00
Why is wakeorpoweron shown twice, you ask? Take a look at /Library/Preferences/SystemConfiguration/com.apple.AutoWake.plist and you will see that one wake and one poweron event is scheduled for 2pm. In fact, if you are really brave and know XML, you can take your chances with editing this file by hand. That's not recommended, though.

[ Reply to This | # ]
Set different startup times for different days
Authored by: frijole on Jan 27, '06 03:55:54PM
the only thing about using schedue is its a one-shot thing, for a specific date/time, so you'd have to set a ton of them. and likely, there would eventually be a limit when you run out of room in the PMU

pmset allows you to schedule system sleep, shutdown, wakeup and/or power on. "schedule" is for setting up one-time power events, and "repeat" is for setting up daily/weekly power on and power off events.

[ Reply to This | # ]

Set different startup times for different days
Authored by: krunk7 on Apr 21, '08 06:31:40PM

To expand upon the suggestion above, you could write a script which set the schedule for the following week and put that in your cron to run weekly.

A script that set two wakes (6:30am and 5:30pm) and two sleeps (9am and 10:30pm) for each day would look something like this: (ruby)

#!/usr/bin/ruby
#

def build_schedule(wake, shutdown)
  days = {'Sunday' => Array.new, 
          'Monday' => Array.new,  
          'Tuesday' => Array.new, 
          'Wednesday' => Array.new,
          'Thursday' => Array.new,
          'Friday' => Array.new, 
          'Saturday' => Array.new}
  t = Time.now
  t = t + (60*60*24)
  days.each do |k,d|
    days[t.strftime('%A')] = [t.strftime("%m/%d/%y #{wake}"), t.strftime("%m/%d/%y #{shutdown}")]
    t = t + (60*60*24)
  end
  days
end

sched1 = build_schedule("6:30:00","9:00:00")
sched2 = build_schedule("17:30:00", "22:30:00")

[sched1,sched2].each do |s|
  s.each do |k, v|
    wake = "pmset schedule wakeorpoweron '#{v[0]}'"
    shutdown = "pmset schedule shutdown '#{v[1]}'"
    system(wake)
    system(shutdown)
  end
end



[ Reply to This | # ]