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

Set different startup times for different days System
The Energy Saver preference pane only allows you one rule for automatic startup, so if you want to have the machine start at, say, 5:30am on weekdays, but not until 7:00am on weekends, you're out of luck. This is becuase the PMU can only store one pair of scheduled rules, one for shutdown/sleep and one for startup. You can, however, write directly to the rules via the pmset command line utility. So to enable scheduling two different rules, we're just going to set up a couple cron tasks to change the rule on Friday and Sunday.

For cron tweaking, I like CronniX. It's pretty straightforward, and makes it a little easier than firing up a command-line editor. Once you open CronniX, you should change to the root crontab, by using the File: Open User's Crontab menu itme, and then entering root as the user. It should ask you to authenticate, and then show that the current crontab is that of root.

Now we'll add two rules, one for Friday to change it to the weekend startup time, and one for Sunday to change it to the weekday time. I set these to run at noon on both days, or you may prefer to have them run about 10 minutes after the scheduled boot for that day, to make sure the system isn't aleep when it's time to run them. Here's the command to use to set the schedule:
pmset repeat type weekdays time
Here's what each argument means:
  • The type can be one of the following: sleep, wake, poweron, shutdown, or wakeorpoweron.
  • The weekdays value is a subset of MTWRFSU. Strings such as M, MTWRF, and SU are all valid, meaning Monday, every weekday, or Saturday and Sunday, respectively.
  • The time is of the format: HH:mm:ss (in 24 hour format).
So bringing this all together, I used the following two commands, the first on Friday, and the second on Sunday:
pmset repeat wakeorpoweron SU 7:00:00
pmset repeat wakeorpoweron MTWRF 5:30:00
This screenshot shows what my CronniX looked like when I was done.

This same method could be applied to setting startup times to be different for different periods, just by changing the day/time of the command, as well as the cron task to run the day before the change is to take effect.
    •    
  • Currently 2.25 / 5
  You rated: 2 / 5 (4 votes cast)
 
[17,865 views]  

Set different startup times for different days | 7 comments | Create New Account
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: Tomnibus on Dec 30, '05 08:48:44AM

This is great in case you want to put your machine to sleep or off but have it automatically wake at 4am for the daily/monthly/weekly scripts, then go to sleep again at 5am and wake again at 8:30am if you want it. You set the crons to execute the different commands when it wakes.



[ Reply to This | # ]
Set different startup times for different days
Authored by: alblue on Dec 30, '05 01:48:04PM

Just to be pedantic; weekdays aren't always MTWTF. In Arabic states, they're quite often SSMTW. I'm presuming though that the letters are still the same, since they're compiled into the operation of pmset rather than being internationalised.



[ Reply to This | # ]
Set different startup times for different days
Authored by: jowel on Dec 30, '05 01:48:23PM

Is it possible to "ignore " startup/shutdowntimes for a specific day (ie: sunday)? I ve got a keynote presentation running 6 days a week on 13 different locations. Macs startup/shutdown automatic. Would be nice if I could leave the machines off on sunday!



[ Reply to This | # ]
Set different startup times for different days
Authored by: altglbrs on Dec 30, '05 02:10:55PM

I'm fairly certain that pmset in 10.3 does not support this hint.

I couldn't get pmset to work in 10.3 as it does in 10.4. In fact, I had to roll my own command line utility to add my own event to the PM queue. If anyone needs this functionality in 10.3, I can provide the the source to the utility..



[ Reply to This | # ]
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 | # ]