16 - Nov - 2026

My home server knows when the power is going out and shuts down before disaster

It’s reassuring to have a battery backup on a home server. But it felt less comforting when I realized my entire home network would still go dark without warning once the backup power ran out.

This realization kept me watching the battery percentage and guessing when to turn off the server. Luckily, the server can make the call itself; I just needed to give that job to a tool called Network UPS Tools (NUT).

It never gets a warning

NUT just keeps asking the UPS one question

Servers don’t know when the power is out, but NUT can change that. By default, NUT’s UPSMON checks the UPS status exposed by UPSD every five seconds. The driver separately polls the UPS hardware, so the exact detection delay depends on both parts of the chain.

Here is the report I got from running upsc command after unplugging the UPS from the wall on a charged battery:

Reading

Before

After

ups.status

OL CHRG

OB DISCHRG

input.voltage

229.0

0.0

battery.voltage

27.1

25.9

battery.charge

97

97

I disconnected the UPS from mains power at 21:17:38, and the journal logged “on battery” at 21:17:41. This three-second lag falls inside the five-second polling interval. The battery charge doesn’t update as rapidly as the status and voltage readings, so it stayed at 97.

Three important elements make detecting power outages and getting the information to the server possible. A driver talks to the hardware (usbhid-ups, for my UPS), UPSD (NUT’s server process) publishes that information, and UPSMON decides what to do with it. Merely being on battery alone will not trigger a shutdown.

NUT also has a 15-second DEADTIME by default. If status updates stop for longer than that, UPSMON marks the UPS dead. If it was last known to be on battery, NUT treats the loss of communication as a possible low-battery condition and may force a shutdown.

Low battery is an estimate

Doing the math on how long my server really needs

06 Calculating shutdown budget
Afam Onyimadu / MUO

Combined, my server, switch, and access point drew 62W, about 7% of my UPS capacity. Using the manufacturers’ runtime figures, which cover half- and full-load conditions and exceed my 62W load, I couldn’t estimate how long my UPS would last. So I had to measure.

I used a 62W dummy load to run two full discharges, stopping at the battery cutoff to avoid deep discharge. At the start, the UPS estimated 88 and 87 minutes, but the battery lasted 66 minutes and 5 seconds and 64 minutes and 40 seconds. In both runs, the initial estimate was about a third higher than the runtime I measured.

The UPS raised its low-battery flag at 10% charge, even though its reported runtime was still 520 to 540 seconds, above my 300-second threshold. That suggests the charge threshold may have triggered the flag, although the readings alone don’t prove which condition caused it. In my two tests, the flag appeared 305 to 330 seconds before cutoff.

Shutdown typically takes between 31 and 37 seconds. Budgeting five seconds for detection lag, the worst case is about 42 seconds. So the flag still leaves about seven times the time required for a safe shutdown.

Low-battery trigger

Timer on battery

Starts when

The UPS reports low battery

The server has been on battery for a set time

Good at

Ignoring short blips

Not depending on the UPS’s estimate

Watch out for

A threshold that leaves too little time

Must be canceled if power returns

My configuration starts a 10-minute countdown when the UPS switches to battery power and cancels it if mains power returns before the timer expires. However, it starts the server shutdown if the countdown reaches zero first.

Under my test load, the UPS lasted about 66 minutes. This means the server shuts down in approximately 10 minutes and 42 seconds into an outage, leaving about 55 minutes of the measured runtime unused. This is more of an estimate from my test than a guarantee for a real outage. Some UPS models allow low-battery threshold adjustment, depending on the UPS and driver.

The ten-second clock

What a clean shutdown protects that a sudden cut doesn’t

07 NUT driver configuration
Afam Onyimadu / MUO

After a power cut, a server may boot normally and still have damaged data. Ext4 and other journaling file systems can recover their own internal records, but they can’t finish a database transaction or save a file interrupted mid-write. A clean shutdown gives applications time to finish pending work and close files before the power disappears.

By default, Docker waits 10 seconds after sending a container’s stop signal before killing it. I used a small homemade container that ignores SIGTERM (the signal that asks a process to stop) to test it. The test container ran the complete 10 seconds before exiting with exit code 137.

I checked my PostgreSQL 16 container and found the stop_grace_period was set to 60s. Running time docker stop postgres took 2.1 seconds with the database idle and 9.4 seconds while it performed a bulk import. That second value was too close to the ten-second timeout, which may be a gamble on a busier database.

In my setup, containers stop concurrently, so the slowest one sets the length. So, while NUT starts the shutdown, I have no proof that all applications finished safely.

Pulling the plug on purpose

It took 32 seconds from command to poweroff when I ran upsmon -c fsd at 100% charge, but this only proves a shutdown path. I also wanted to see whether NUT would detect a real outage. So at 97% charge, I unplugged my UPS after temporarily setting the timer to two minutes.

Test timeline:

Time

Event

21:17:38

UPS unplugged

21:17:41

On battery detected

21:19:41

Timer fires, shutdown starts

21:20:12

Power off completed (31s after shutdown started)

21:21:10

Mains restored

~21:22:30

Server back up

The test also revealed that my ISP router was plugged into a wall socket. Unplugging dropped the internet while the home server stayed running.

NUT can’t predict a power outage, but my server can now notice one, decide when to shut down, and leave room for its applications to stop. That’s more than a regular battery backup gives you.

Leave a Reply

Your email address will not be published. Required fields are marked *