Controlled Shutdown of your NAS(es) in case of defined Level of Battery in UPS

Currently reading
Controlled Shutdown of your NAS(es) in case of defined Level of Battery in UPS

I have a Cyberpower UPS connected to my NAS, which i want to tell my computer to power down 30 mins after a power cut.

But I can't even work out how to install NUT and get to the GUI.
"Windows (complete port, Beta): Windows MSI installer 2.6.5-6"
Just seems to dump a load of files in Program Files (X86).

Cany anyone give me a pointer please, on how to configure NUT ? I have been able to install it, but none of the information appears to be for Windows, everything is re linux.

What I'm trying to achieve is the NAS to tell the desktop when to shutdown...
Last edited:
Guide, how to setup Windows NUT client (incl GUI)

Guide, how to setup Windows NUT client (incl GUI)


What a champion - thank you very much.

The odd thing is that DSM and NUT approach shutdown in different ways:

- DSM will shutdown with low battery (amount unknown??), or after x amount of time on battery
- NUT will shutdown if battery less than x, or if runtime is lower than x

So there isn't really a best option for the settings, because it is entirely possible that the DSM shuts down prior to a NUT threshold being reached. It's weird that they would approach the same problem in different ways, or at least, not give you the option to choose one or the other.

So the solution is based on a best guess, rather than being able to say "battery less than 40%: shut down PC, battery less than 30%: shut down NAS"
all of my NASes will shut down when the batt level is under <=XX%
when you will setup defined in this thread you will get same option
-- post merged: --

# For the proper Shutdown of the NAS we have to test 2 scenarios:
# First: UPS in on Battery from the "$STATUS" variable
# Second: UPS battery level is Equal or Lower than variable (in my case = 20%)
if [ $BATINT -le 20 ] && [ $STATUS = 'OB' ];

$BATINT -le 20 ... is the feature
Thanks @jeyare . I haven't used bash/ssh at all with the DSM because I am scared of destroying it, only with a Raspberry Pi where I am "practising", so maybe this is something for the future.

don't worry, you will use the RESET button a few more times and you will be a master in resetting. I already have a lot of such 'honorable' titles ;)
don't worry, you will use the RESET button a few more times and you will be a master in resetting. I already have a lot of such 'honorable' titles ;)
that's what i want to avoid... i have no idea what the rammifications are and as a noob it would take me ages to set everything up again!

then again - i could just back up the config file and assume that would take care of the synology packages.....
Updated setup for newbies:

Creation and Edit of the User-defined script for Shutdown
1. Download the attached file "".
2. Unzip it somewhere on your computer.
3. It will create a new file ""
4. Open "" in your preferred simple text editor (no MS Word), e.g. Notepad and make simple edition in row no. 32:
if [ $BATINT -le 20 ] && [ $STATUS = 'OB' ];

- there is the number '20' in the code
- it is variably defined value in % of your UPS battery status for the NAS shutdown threshold ... then value 20 means 20% of the battery remains
- you can change the value to whatever value, up to you. 30 = 30%; 25 = 25%
- when the UPS battery will reach this value (%) and NUT upsmon (monitor) will get this information from NUT upsc (status) it will automatically run $SHTD, in this case, SHUTDOWN of the NAS.

Save the file.

Deployment of the "" file to the NAS
1. Use putty or something quite better for 'ssh' into your NAS - in my case I like more the MobaXterm

2. Create a session (plenty of guides here or on the Internet, YT). You need: IP address of the NAS, admin usr/psw.
4. Use 'sudo -i' to get root session
5. In the MobaXterm terminal you can find in the left upper part (arrow) menu for upload a file. But you need to open a working directory first. So open 'opt' directory (this will be not overwritten after NAS upgrade)
click there
when opened, use UPLOAD ICON and upload the file "" into your working directory:

You can use REFRESH green icon (right next to).
So, when everything is OK, then you will see the file "" within 'opt' directory.
6. in the terminal window type:
chmod +x /opt/
to allow executable permissions for the file.
Done. Exit the terminal

Define cyclic check of the battery status in DSM
In DSM Control panel / Task Scheduler:
Create / Scheduled task / User-defined script
General tab:
Task: name of the Task ----up to you
User: root

Schedule tab:
use these values from screenshot

Task settings tab:
Run command/User-defined script type (use the chosen path to the script):
bash /opt/


Done. Use OK, then just check if the Task is ENABLED, select it and use RUN:

Now you can open a beer or two and call me to celebrate this task! 🍻

With this small script you will get:
Controlled Shutdown of your NAS based on EXACT battery level, e.g. 20%.
Performed only when is the UPS on Battery (no one wants shutdown of charged UPS) :cool:

Last recommendation:
- when something is wrong or just for a check, you can find ERROR LOG within:
- right click, then 'Open with Default Text Editor'
- then Ctrl+F to find related error



    634 bytes · Views: 31
  • 1640005376827.png
    8.8 KB · Views: 18

Create an account or login to comment

You must be a member in order to leave a comment

Create account

Create an account on our community. It's easy!

Log in

Already have an account? Log in here.

Similar threads

  • Question
Thanks Rusty. Appreciate the help and your knowledge. :)

Welcome to! is an unofficial Synology forum for NAS owners and enthusiasts.

Registration is free, easy and fast!