# Configuring Nut for delayed shutdown

## MacGyver031

Hi,

I have read some Nut configuration pages, but I do not see it through. I will specify my case:

We have a headless Gentoo server with Nut running. I would like to configure Nut so that if there is a power failure, system will be running 5min on battery and then shutdown otherwise. If the power is restored withing 5min, then the system does not shutdown at all.

So for what I have read: Some say that the shutdown is initiated when the battery is running low (to the dimension of my ups, this should be over 10min).

Others say that the shutdown is called immediately (which is not so good for me, because we have very short power loss, but bigger blackout is very rare).

So, am I correct that I should setup the upssched.conf and a external shutdown-execute-command-file, and remove the SHUTDOWNCMD in upsmon.conf?

Or is there any "easier" way to configure Nut?

Thanks.

----------

## MacGyver031

Well, now I have read something which clears up a little:

 *Quote:*   

> The whole point of UPS software is to bring down the OS cleanly when you run out of battery power. Everything else is roughly eye candy.

 

And my upsc states:

 *Quote:*   

> battery.runtime: 1440
> 
> battery.runtime.low: 120

 

So that means that my server will be running about 10-24min depending on the load and then it has about 2min to shutdown.

Soo, in my case, I should look for the "ONBATT" event and start the timer for 600s. As soon as 600s have passed, my script should call the "shutdown -h now".

If the power is restored, then I should CANCEL-TIMER. Can anyone confirm that it is so?

Thanks.

----------

## jmartos

That is the way I have my UPS set up with NUT. One timer is started when on battery alert is signaled and the timer is cancelled when power is restored. I do have my on battery timer set to a much lower time than what the UPS can handle since I also want to take care of cases where power is repeatedly interrupted after an initial interruption. You don't want to drain your batteries on the first power interruption and not be able to support subsequent interruptions. This may not apply to you, but I wanted to avoid that condition since the batteries would take longer to recharge and the maximum time on UPS power would change. Hope that helps.

----------

