Quantcast
Channel: rtrouton – Der Flounder
Viewing all articles
Browse latest Browse all 764

Using pmset on OS X to schedule restarting your Mac

$
0
0

OS X’s pmset command line tool is designed to control power management settings on your Mac, but it also has various options for scheduling your Mac to perform various actions at set times using the following format:

pmset repeat type weekdays time

The various types documented in pmset’s man page are as follows:

  • sleep – puts the Mac to sleep
  • wake – wakes the Mac from sleep
  • poweron – starts up the Mac if the Mac is powered off
  • shutdown – shuts down the Mac
  • wakeorpoweron – depending on if the Mac is off or asleep, the Mac will wake or start up as needed

The weekday options are as follows:

  • M = Monday
  • T = Tuesday
  • W = Wednesday
  • R = Thursday
  • F = Friday
  • S = Saturday
  • U = Sunday

The time option documented in the man page is as follows:

  • HH:mm:ss

The time must be set in 24 hour format, with a leading zero for numbers less than 10.

Examples of this would be:

4:00 AM = 04:00:00
1:00 PM = 13:00:00
12:00 AM (midnight) = 00:00:00

These options all match what shows up in the Energy Saver preference pane’s scheduling options, with one exception. There is a Restart option in the Energy Saver settings which doesn’t appear to have a documented type in the pmset man page.

Screen Shot 2016 02 26 at 10 23 05 PM

 

The answer turns out to be that there is a undocumented restart type which is not listed on the pmset man page. For more information, see below the jump.

This restart type can be used like the other types with pmset. For example, if you want to schedule a Mac to automatically restart every day at midnight, run the command shown below with root privileges:

/usr/bin/pmset repeat restart MTWRFSU 00:00:00

Screen Shot 2016 02 28 at 7 11 00 PM

 

If you want to schedule a Mac to automatically restart at 11:59 PM on Monday, Wednesday, Friday and Sunday, run the command shown below with root privileges:

/usr/bin/pmset repeat restart MWFU 23:59:00

Screen Shot 2016 02 28 at 7 11 28 PM

Once a schedule has been set, the Mac will restart at the specified times. If the Mac is logged in, a dialog window similar to the one shown below will appear.

Screen Shot 2016 02 29 at 12 00 04 AM

 

The desired restart time should show up in the Energy Saver preference pane’s scheduled options, which is accessible using the following procedure:

1. Open System Preferences
2. Select the Energy Saver preference pane

Screen Shot 2016 02 28 at 7 09 28 PM

3. Click the Schedule… button

Screen Shot 2016 02 28 at 7 09 45 PM

4. The desired schedule should be listed.

Screen Shot 2016 02 28 at 7 11 39 PM

 

Note: If you have selected several, but not all weekdays, the schedule window will display Weekdays for the daily interval.

Screen Shot 2016 02 28 at 7 31 36 PM

 

You can also check the settings in the following file:

/Library/Preferences/SystemConfiguration/com.apple.AutoWake.plist

Screen Shot 2016 02 28 at 7 12 59 PM



Viewing all articles
Browse latest Browse all 764

Trending Articles