pmset
is a swiss army knife of functionality for sleep, standby, UPS, scheduled event, and power source debugging, The examples in the man page show some uses of most of them. My remote mac is a desktop without an uninterruptible power supply (UPS) so I need a simple power regime to make sure my Mac mini is on for remote backup when I need it to be online - this is exactly what used to be possible via System Settings.
pmset -g
Lets first check what is currently set on my Mac, upgraded from macOS Monterey to macOS Sonoma. (Annotations mine)
% pmset -g
System-wide power settings:
Currently in use:
disksleep 10 - Disk spindown timer; (value in minutes, or 0 to disable)
powernap 1 - Enable/disable Power Nap on supported machines (value = 0/1)
womp 1 - Same as "Wake for network access" in System Settings.
networkoversleep 0 - This setting is not used by all platforms; changing its value is unsupported
sleep 10 - (sleep prevented by sharingd, powerd, bluetoothd)
Sleep On Power Button 1 - Not documented
ttyskeepawake 1 - prevent idle system sleep when any tty is 'active'. (value = 0/1)
tcpkeepalive 1 - Not documented
autorestart 1 - automatic restart on power loss (value = 0/1)
standby 0 - kernel power management to automatically hibernate (setting visible if the feature is supported on this machine)
displaysleep 10 - display sleep timer (value in minutes, or 0 to disable)
Not sure if ttyskeepalive
respects Apple Remote Dektop (ARD), but I hope so! The disksleep
parameter seems a bit weird. All Mac computers have been SSD for years now. There is no disk to 'spindown'. And standby
is a bit weird too. This is a Mac mini - it wouldn't normally hibernate. Ignoring these for now.
pmset scheduled events
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. Note that you may only have one pair of repeating events scheduled - a "power on" event and a "power off" event. For sleep cycling applications, pmset can schedule a "relative" wakeup or poweron to occur in seconds from the end of system sleep/shutdown, but this event cannot be cancelled and is inherently imprecise" - Source: pmset Man page
type - one of sleep, wake, poweron, shutdown, wakeorpoweron
date/time - "MM/dd/yy HH:mm:ss" (in 24 hour format; must be in quotes)
time - HH:mm:ss
weekdays - a subset of MTWRFSU ("M" and "MTWRF" are valid strings)
owner - a string describing the person or program who is scheduling this one-time power event (optional)
This is obtuse for 2023. Weekdays have letters to describe them, in a way so as to have a unique letter for each day. Old school Unix I guess. Not very 'global'. Anyway, for my purposes for one particular Mac Mini I want it to power on on Saturday at 09:00 and shutdown at 21:00 so the command which has to be run by sudo is :-
sudo pmset repeat wakeorpoweron S 09:00:00 shutdown S 21:00:00
You can check that is set correctly using % pmset -g sched
% pmset -g sched
Repeating power events:
wakepoweron at 9:00AM Saturday
shutdown at 9:00PM Saturday
...
And for another Mac I want the machine to wake each morning in time for my morning routine.
% sudo pmset repeat wakeorpoweron MTWRFSU 09:00:00 shutdown MSU 18:30:00
% pmset -g sched
Repeating power events:
wakepoweron at 9:00AM every day
shutdown at 6:30PM Some days
...
Now that is set I can go ahead and configure my backup regime content that my machine will be up all day Saturday to run it. That's another story..