Using pmset on OS X to schedule restarting your Mac
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:
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.
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
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
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.
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
3. Click the Schedule… button
4. The desired schedule should be listed.
Note: If you have selected several, but not all weekdays, the schedule window will display Weekdays for the daily interval.
You can also check the settings in the following file: