MacOS – Mac does not automatically restart when power is re-applied after `shutdown -hu now`

macospowershutdownsleep-waketerminal

I want to have a Mac Mini automatically boot when power is applied, as I cannot conveniently reach its power button, because it resides inside an art installation, where the power will be shut down during the night. I thought it might be possible to use the "Start up automatically after a power failure" in the energy system settings for this, along with the -u parameter to the shutdown command, in order to safely bring the machine in a state where I don't have to fear data loss. According to the shutdown man page, the -u parameter seems to be what I need:

-u: The system is halted up until the point of removing system power, but waits before removing power for 5 minutes so that an external UPS (uninterruptible power supply) can forcibly remove power. This simulates a dirty shutdown to permit a later automatic power on. OS X uses this mode automatically with supported UPSs in emergency shutdowns.

But shutdown -hu now does not work. On both Macs I tested it with (Mac Mini with 10.10 and a Mac Pro on 10.11), the machines still power off immediately, they do not wait for five minutes in the halt state, so that I don't have the time to power off the mains. Therefore, the autostart on power failure setting doesn't trigger, and I have to manually push the power button to make them boot again.

Best Answer

The NVRAM setting to power on when power returns has nothing to do with the shutdown command, so I wouldn't worry about the shutdown options and instead focus on the NVRAM settings for what to do when the machine senses a return of power.

If you don't have an actual UPS - I would get an internet enabled power switch like WeMo or other or just train staff to power cycle the hardware.

The setting to power on automatically is quite reliable in my experience, so you should only need that to recover from 95% or more of the power failure events you have. Also, kiosk machines generally just run apps and open files, so you don't have work that needs to be saved to disk. I would just let the power cut from the Mac and make sure the filesystem is journaled so that the restart is quick.

enter image description here

If you have an actual UPS - use the energy saver control panel to tell the OS to shut down N minutes before the power runs out and you will be well protected from data loss.

enter image description here

Here I have a server with storage attached so I'm having the shut down scheduled 10 minutes before the battery expires. For a kiosk, I would disable all three sliders/check boxes for UPS or get a simple UPS like APS BGE70 that lacks USB port entirely and just gives you some time when people accidentally trip the power or a substation feeder shifts and your outage is a minute or so in length.