Shutdown via SSH

I’m having some problems when I try to shutdown the EX2 via SSH.  I login and issue the poweroff command, and get immediately disconnected from ssh.  ALL lights remain on, and I can’t ping the EX2.  The only way to recover is to pull the power cord.

Am I issuing the incorrect command?  Is anyone having the same issue?

Thanks.

1 Like

Welcome to the Community.

Hopefully an experienced User will be able to assist.

Do not use “poweroff”, use “halt”.

1 Like

Correct. Halt will power off completely after 30-45 seconds

2 Likes

hi

use “shutdown -h now” 

it will be turned off , and u can turn it on again via wake on lan

1 Like

david001 wrote:

 

it will be turned off , and u can turn it on again via wake on lan

David, has wake-on-lan worked for you wih the EX2? I was under the distinct impression it doesn’t on EX2.

yes WOL works great for me

i’m using  Depicus Wake On Lan , tested it in both LAN & WAN and  it works correctly

1 Like

david001 wrote:

yes WOL works great for me

i’m using  Depicus Wake On Lan , tested it in both LAN & WAN and  it works correctly

 

Thank you David for telling me about this. I just tried it and it works. I was all along under the impression that WOL does not work on EX2 but you are absolutely correct, sir. It does work on EX2. Sometimes even veteran EX2 users can learn useful stuff from others :slight_smile: I always could restart or shutdown the EX2 over the Internet via the dashboard but with this capability, I can now shut it down and restart much later at any time. This is really useful. Thanks again.

For others interested, check out this quick YouTube tutorial on how to use the free tool David001 mentioned, here →   https://www.youtube.com/watch?v=onP-lo-6V3Q   The relevant part of the tutorial starts at the 2:35 mark (making the batch file part - but the part between 1:27 to 1:57 is also needed and relevant…skip all the other stuff until the 2:35 mark).

To get the MAC address of your EX2, SSH in, type the command shown in the pic below and press enter. The EX2’s MAC address will be the six pairs of alphanumeric characters separated by colons (redacted partially in the pic for security reasons). The MAC address can then be used as demonstrated in the YouTube tutorial (above) but leave out the colons. Another thing, this will work best if you assign a static IP to the EX2 on your router beforehand (some call it reserving an IP on the router). This gives you the capability to remotely startup your EX2 over the Internet if it crashed for some reason or was shut down deliberately by you. Of course to do this over the Internet you’ll also have to setup port forwarding for port 3389. Without that port forwarding, you can still use this to remotely start up the EX2 as long as your other computer is within the same network as the EX2 is. Good luck!

If this helps you, please click the star on the left under my username to give me a kudo.

“Shutdown -h now” does not work on my EX2, in that case only halt will work. 

To find out the MAC adress for your EX2 you simply take a look at the type lable. There you can find the MAC adress.

WOL works fine with the EX2.

you can use “shutdown.sh”

2 Likes

david001, so excited to stumble upon this thread! I have a question for you. I am successfully using the same utility as you for wake on lan, after using the shutdown.sh command to shut down. It works, but when it wakes and I try to log in to the My Cloud home page, it gives me this error message:

Note that I have not removed power by unplugging it, but just issued the shutdown.sh command. Does this mean the drive is shutting down dirty? It makes me nervous to use the shutdown.sh command…

Thanks for any help.

Also getting this in the event log each time:

Following events are generated on your WDMyCloudEX2 .

Event title:Power loss detected

Event description:Power loss detected on port 1.

Severity:warning

Event code:1022

Event time:02-02-2016 01:24:01 PM

Firmware version: 2.11.133

Well, If you like DIY Projects you may try this :grinning: -

you can find all the details at this link -

1 Like

I wrote a bash script to shut this down for me during a proc of my APC UPS. Problem was that issuing the straight command was hanging up bash, so…

My solution on Ubuntu Server (the machine that will shut down all other computers and Virtual Machines on my network), that my UPS communicates with:

sudo -s

apt-get install sshpass -y

nano /root/.ssh/NASpass

Type your Mycloud’s SSH password and then save the document ( ctrl+x → y → enter )

chown 600 /root/.ssh/NASpass

mkdir /root/scripts

nano /root/scripts/shutdown_NAS.sh

copy paste the following script (making sure to change the IP address to w/e your NAS is) and save it:

#!/bin/bash

sshpass -f /root/.ssh/NASpass ssh root@XXX.XXX.X.XXX "shutdown.sh"

Issue the following command from bash terminal…

timeout 30 /root/scripts/shutdown_NAS.sh

it will shutdown the NAS and then not hang up the bash

you can then put the command inside other scripts if you want (can only be run as root on your host machine, though, unless you’re cool with having the password for your NAS dangling out there…)

Hope this helps!

***** DO NOT USE HALT *****
Use shutdown.sh as some have already suggested. This is not the same Linux shutdown, it is a shell script that executes many procedures before shutting the device down. Otherwise, you are very likely to corrupt your disks and losing data.
@Matt87 solution is the best one if you want to do it remotely.

I take it this no loner works with either a revision of the hardware or a new firmware

Do please correct me if I’m wrong, but isn’t it overstating it to say that with a “hard” shutdown, you are “very likely to corrupt your disks and lose data”. In the knowledge base article on “How to Shut Down a My Cloud Device”, it says…
“Removing the power cord from the unit or the power outlet can be used to Power Off”

Of course that doesn’t seem the ideal way to do it! But I had some electricians cut power to my NAS drive unexpectedly and it was shut down in this manner. I came across this thread in my subsequent searches on how to actually shut the NAS drive down properly.

it’s been a while since you posted this, but maybe if you’re still listening you could help me ?

i want to add a script to my EX2 that runs at startup - that can listen to messages from the UPS and take action … is that possible ?

i tested my EX2 running on and connected to a UPS and it receives messages when the UPS disconnects from main power, when the battery is at 50%, then 15%, then critical. But the NAS is not doing any controlled shutdown … it dies along with the UPS battery.

i was hoping to add a script that allows the nas to execute “shutdown.sh” when it senses that the UPS has lost mains power and is running on battery.

should be a basic function of NUT on the backend, but for some reason WD didn’t provision it correctly or there is something wrong with OS5.