[Nut-upsuser] turn UPS off after PC shutdown

Dario Novakovic darionis at yahoo.com
Wed Jun 18 14:30:45 BST 2025


Ok, I've figured it out.


File /etc/killpower actaully exists but command that is supposed to check for it (upsmon -K) incorrectly exits with "1". When I run that command in debug mode, it complained that nut service is still running
So, it is some kind of timing problem "upsmon -K" is supposed to be run later in the shutdown procedure, when the nut service is stopped, I guess.

$>upsmon -K
Network UPS Tools upsmon 2.8.0
Fatal error: A previous upsmon instance is already running!
Either stop the previous instance first, or use the 'reload' command



Anyway, I can check for the presence of the /etc/killpower file and turn the ups off, like it is suggested on the forums:
if [ -f /etc/killpower ]; then until upsdrvctl shutdown; do sleep 1; done; fi

This has to be added as "Trunas shutdown script".




Thanks to Jim for inspiration :)

Dario






On Tuesday, June 17, 2025 at 02:12:35 PM GMT+2, Dario Novakovic via Nut-upsuser <nut-upsuser at alioth-lists.debian.net> wrote: 


Exactly Jim,  this bothers me too much to give up :)

My upsmon.conf *does contain* line: POWERDOWNFLAG /etc/killpower

I checked for the existence of the file during shutdown with "/sbin/upsmon -K", and it exited with "1", meaning error: no POWERDOWNFLAG.


It is actually Truenas 25.04, with NUT 2.8.0. This may be Truenas issue, but I would like to check NUT first.

Now, for the logs: all I see about killpower is this line
     nut-monitor[2688]: Using power down flag file /etc/killpower
and it is logged when NUT service is starting. Thats all. No errors.


I attached log of the shutdown procedure. Truenas is configured to shutdown in 60 seconds after power failure, and that is OK, but nothing about "killpower".


Now I wonder what creates POWERDOWNFLAG, and why it is not created.  I attached shutdown log, removed uneeded lines. Truenas is configured to wait 60 seconds and if power is not restored it shuts down.

Thanks,
Dario




More information about the Nut-upsuser mailing list