UPS Integration With NUT: Shutdown Before the Battery Dies
Bottom line: A UPS buys time to shut down cleanly, and without NUT the machine runs until the battery collapses and the filesystem takes the hit. NUT watches the UPS, triggers a shutdown at a set charge, and turns the machine back on when mains returns if the BIOS allows it.
Components
nut-serverwith the UPS driver matched to the modelupsmonon every host that must shut down- BIOS: “restore on AC power loss” enabled
Driver
1 | # /etc/nut/ups.conf |
nut-scanner -U finds the VID/PID; then upsdrvctl start and confirm with upsc main.
Watch state and act
1 | # /etc/nut/upsmon.conf |
Trigger on LB (low battery) by default. If the expected runtime exceeds the shutdown time, use ONBATT with a timer instead:
1 | NOTIFYCMD /usr/local/bin/ups-handler.sh |
The handler shuts down after a configurable 180 s of ONBATT, giving short outages no downtime and long ones a clean exit.
Auto-restart
BIOS “AC restore → power on”, plus systemctl enable nut-monitor. After an outage the host comes back unattended; without the BIOS setting it waits for someone to press a button at 3 a.m.
Testing
The only acceptable test pulls mains at the wall, on purpose, with work open. Confirm: notification fires, shutdown starts on schedule, machine powers off before the battery empties, and it returns when mains returns. A UPS that has never been tested is a heavy box.
Battery care
Sealed lead acid degrades in about 3–5 years. Log battery.runtime monthly; a runtime that has halved means the battery is due, and the UPS buys less time than the configuration assumes.
Operating notes
A UPS buys time to shut down; without NUT the machine runs until the battery collapses and the filesystem takes it.
1 | MONITOR main@localhost 1 admin secret master |
Trigger on a timer, not just LB
If expected runtime exceeds the shutdown time, act on ONBATT after 180 s rather than waiting for low battery.
Auto-restart
BIOS “AC restore → power on” plus systemctl enable nut-monitor. Without the BIOS setting the host waits for a button at 3 a.m.
Test at the wall
Pull mains on purpose, with work open: notification fires, shutdown starts on schedule, power-off completes before the battery empties, host returns when mains returns.
Battery care
Log battery.runtime monthly; a halved runtime means the battery is due and the configuration is assuming time the UPS no longer has.
FAQ
What happens if I run a UPS without NUT installed?
The machine runs until the battery collapses, and the filesystem takes the hit. A UPS alone only buys time; without NUT nothing triggers a clean shutdown at a set charge. NUT watches the UPS and starts the shutdown before the battery is empty.
How do I find and start the right UPS driver?
Run nut-scanner -U to find the VID/PID, then set the driver and port in /etc/nut/ups.conf — for example usbhid-ups with port = auto. Start it with upsdrvctl start and confirm it is working with upsc main.
Should I trigger shutdown on low battery or on ONBATT?
Trigger on LB (low battery) by default. If the expected runtime exceeds the shutdown time, use ONBATT with a timer instead — the article’s handler shuts down after a configurable 180 s of ONBATT, so short outages cause no downtime and long ones get a clean exit.
How do I make the machine power back on after an outage?
Enable “restore on AC power loss” (AC restore → power on) in the BIOS and run systemctl enable nut-monitor. With both in place the host comes back unattended after an outage; without the BIOS setting it waits for someone to press a button at 3 a.m.
How do I test that the whole setup actually works?
Pull mains at the wall on purpose, with work open. Confirm the notification fires, shutdown starts on schedule, the machine powers off before the battery empties, and it returns when mains returns. A UPS that has never been tested is a heavy box.











