Wilkie Posted February 16, 2022 Share Posted February 16, 2022 Hello, what command should I be using to shutdown unraid? I have looked at /sbin/poweroff but unraid documentation says it is not sufficient or deprecated. Should I be using shutdown -f ? Does it safely shutdown unraid? To elaborate my UPS doesn't play nicely with unraid and loses USB connection every few minutes which causes it to not shutdown properly with APC or NUT. As a workaround I'm writing a script that pings a few devices every minute on my network and if successful pings aren't received for 10min or so, then run a shutdown command for unraid to shutdown in the event of a power failure. Thanks for any input. Quote Link to comment
Raki72 Posted September 26, 2023 Share Posted September 26, 2023 On 2/16/2022 at 2:26 PM, Wilkie said: As a workaround I'm writing a script that pings a few devices every minute on my network and if successful pings aren't received for 10min or so, then run a shutdown command for unraid to shutdown in the event of a power failure. Would it be possible to share this script? I am looking for something like that, but don't want to develop it frm scratch... Quote Link to comment
Wilkie Posted September 27, 2023 Author Share Posted September 27, 2023 (edited) Sure, I don't really use it anymore as I found 6.12 to resolve lots of my UPS issues. It currently pings 3 different devices and if it can't successfully ping the devices for about 10 minutes then unraid shuts down. Please adjust according to your needs. #!/bin/bash i=0 while true; do #computer 1 ping -c 1 10.0.1.1 if [ $? -eq 0 ] then i=0 #Pass echo '10.0.1.1 Pass i='$i else ((i++)) #Fail echo '10.0.1.1 Fail i='$i fi sleep 60 #computer 2 ping -c 1 10.0.1.5 if [ $? -eq 0 ] then i=0 #Pass echo '10.0.1.5 Pass i='$i else ((i++)) #Fail echo '10.0.1.5 Fail i='$i fi sleep 60 #computer 3 ping -c 1 8.8.8.8 if [ $? -eq 0 ] then i=0 #Pass echo '8.8.8.8 Pass i='$i else ((i++)) #Fail echo '8.8.8.8 Fail i='$i fi sleep 60 if [ $i -gt 10 ] then /sbin/powerdown fi done Edited September 28, 2023 by Wilkie Quote Link to comment
Raki72 Posted September 27, 2023 Share Posted September 27, 2023 9 minutes ago, Wilkie said: Sure, I don't really use it anymore as I found 6.12 to resolve lots of my UPS issues. It currently pings 3 different devices and if it can't successfully ping the devices for about 10 minutes then unraid shuts down. Please adjust according to your needs. Nice and simple. Thanks! Quote Link to comment
Frank1940 Posted September 27, 2023 Share Posted September 27, 2023 (edited) Just make sure that your router and the local computers you use are not on UPS's as this will add that time onto the time that your Unraid UPS has to supply power. (You always want to make sure that your Unraid UPS battery can last through two full shutdown sequences. (It can take between eight and twenty-four hours to fully recharge a UPS battery...) You might also consider pinging always-on devices like Roku boxes... Edited September 27, 2023 by Frank1940 Quote Link to comment
MarianKoniuszko Posted February 19 Share Posted February 19 On 2/16/2022 at 5:49 PM, Squid said: powerdown Hi, if I setup upsnap (on raspberrypi) for my unraid server (PC on the same LAN) command Like this is OK: ```sshpass -p xjwxnwkdneeeee ssh -o "StrictHostKeyChecking=no" [email protected] "powerdown"```? referring to example: Regards. Quote Link to comment
Coastal Custom Tech Posted March 29 Share Posted March 29 (edited) I stumbled across this entirely by accident looking for the proper shutdown command but came up with the same idea you did. I installed a cheap UPS for a customer to prevent their server from shutting down abruptly as it killed 1 drive already. Here's the code that I used chatgpt to help make, instead of pinging a device on the network I have it ping the gateway itself which works out perfectly here since their network isn't on a battery backup. If you want to use this replace the IP with your gateway and desired timings. #!/bin/bash while true; do printf "%s" "Checking local LAN gateway @ 192.168.86.1..." if ping -c 1 -n -w 1 192.168.86.1 &> /dev/null; then printf "\n%s" "gateway is responding" else printf "\n\n------------------------------------------------------------------------" printf "\n%s" "gateway is not responding, waiting 5 minutes before checking again..." printf "\n------------------------------------------------------------------------\n" # Wait for 5 minutes before checking again sleep 300 printf "\n%s\n" "Rechecking gateway..." if ping -c 1 -n -w 1 192.168.86.1 &> /dev/null; then printf "\n------------------------------------------------------------------------" printf "\n%s" "Gateway is now responding, shutdown avoided..." printf "\n------------------------------------------------------------------------\n" else printf "\n------------------------------------------------------------------------" printf "\n%s" "Gateway is still not responding after 5 minutes, shutting down..." printf "\n------------------------------------------------------------------------\n" powerdown exit 1 fi fi # If the loop reaches here, it means the IP is now responding printf "\n%s\n\n" "Checking again in 30 seconds..." sleep 30 done I also formatted it so in the logs it looks nice and pretty with good spacing for at a glance troubleshooting. Edited March 29 by Coastal Custom Tech Quote Link to comment
JonathanM Posted March 29 Share Posted March 29 5 hours ago, Coastal Custom Tech said: Here's the code that I used Make sure you document how to stop the script from running at startup or kill it when desired, as this would make a future technician absolutely batty trying to figure out why the stupid server keeps shutting itself down for no reason. I know you said you made sure it logs the activity, but if there is a network change, or any other circumstance keeps that IP from responding to a ping... You can see where this could be very bad. If it were me, I might go so far as to only do the shutdown if the gateway was unresponsive, AND a canary file was readable with the correct content on one of the array drives. That way if the array isn't started, or that file is deleted, the server will stay running. Maybe name the canary file POWERFAILSHUTDOWN or something, so the next guy intuitively knows it may be involved in an unplanned shutdown. 1 Quote Link to comment
Coastal Custom Tech Posted March 29 Share Posted March 29 5 hours ago, JonathanM said: Make sure you document For this client specifically it’s just me catering to them but I do have documentation on how I set them up incase I need to look back long term. I made a more advanced version that is also outputting the errors to a file on the array so it can be reviewed long term. For the most part the issues they had was brownouts with the power, or they would trip the break as it shared outlets outside the house that would have power tools on. Since it’s for a small construction company that their house is their office it’s a pretty great solution that covers %99 of their needs. For a bigger customer I would do a bit more and will probably figure out how to make it notify (if a specific device went off that should be on, for the network being on backup), giving a pop on next login, and disabling after a full shutdown to prevent re-accruing shutdowns without intervention first. Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.