[Nut-upsuser] turn UPS off after PC shutdown
Robert Nichols
rnicholsNOSPAM at comcast.net
Fri Jun 13 02:42:59 BST 2025
On 6/12/25 14:30, Jim Klimov via Nut-upsuser wrote:
> Primarily this depends on UPS abilities, whether its firmware allows such operation and implements the (delayed) UPS shutdown.
> Also this needs NUT drivers' INSTCMD support, there are several names for similar operations though (load.off , ups.shutdown.stayoff, ups.shutdown.reboot, etc.)
>
> For CPS, see also https://github.com/networkupstools/nut/wiki/CyberPower-Systems-(CPS)-know-how <https://github.com/networkupstools/nut/wiki/CyberPower-Systems-(CPS)-know-how> - there are nuances about delay/time specification (IIRC each whole 60sec is what matters).
>
> Generally this works like this:
> * driver reports that the UPS is in a critical state (e.g. on battery and low battery)
> * upsmon client which is "primary" for the UPS populates a "killpower" file and begins usual system shutdown
> * init-script or service integration should have a NUT shutdown hook script, late in the shutdown routine (maybe after most filesystems are remounted read-only or unmounted), which finds the "killpower" file and re-runs the NUT driver to command the UPS to power off, possibly with a delay
> * UPS controller handles this - e.g. sleeps some more to let the OS to shut down completely, and turns off the load and/or inverter
> * when wall power comes back, the UPS usually powers on automatically (maybe after charging to a safe level), gives power to the load, computer turns on (if BIOS settings tell it to always turn on when power appears)
>
> Jim
The way I've always handled it is to tell the system to reboot, rather than shutdown (SHUTDOWNCMD "/sbin/shutdown -r +0") and then set "POWEROFF_WAIT=0" in nut.conf. That handles the corner case of AC line power coming back on during the time the OS is shutting down. If that does happen, the system simply reboots and is not left sitting there halted forever. In the usual case of line power remaining off, the system gets its power cord yanked out while the firmware is trying to reboot, and then will actually boot when power is restored.
Works for me. YMMV.
--
Bob Nichols "NOSPAM" is really part of my email address.
Do NOT delete it.
More information about the Nut-upsuser
mailing list