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.

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

1 Like

hi

use “shutdown -h now” 

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

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!

EX2_MAC_Address.jpg

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”

1 Like

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