Jump to content

Scheduled Shutdowns


Recommended Posts

since i moved into a new apartment here in SF, i have taken a closer look at my electricity bill and have noticed that i am usually right up against the Tier 2/3 allowances, where Tier 3 ist almost 3 times as expensive as Tiers 1 and 2.

 

i can see on my UPS that my Unraid server really only draws about 150W during bootup and disk access (15 disks), but usually comes back down to about 90W when sitting idle...amazingly little, but when you run it 24/7, it does add up...and if i could use reductions in this one device to put me solidly within Tier 1/2, that would reduce my electricity bill from - say - $70/mo back down to about $40/mo...that's significant, at least to me.

 

my question: might there be a way to automatically schedule Unraid to go into deep-sleep mode between certain hours (i.e. 12am to 7am)? although the first problem i see with this is that i have yet to manage to do a successful S3 Sleep operation, that doesn't result in me losing contact to Unraid and having to do a hard-reset, resulting in a parity check.

 

pending me getting that - i would think - necessary feature to work correctly, would a scheduled ON/OFF script be possible?

Link to comment

You asked one question (how to do a "scheduled shutdown") but are actually discussing something else (S3 sleep).    Which do you want to do?

 

If you do a scheduled shutdown, as long as you do it correctly, the system will be properly shut down and no parity check will be required when you turn it back on.

 

You can set the system for Wake-on-LAN, and can then easily turn it on from any of your client PC's (or even your SmartPhone or tablet).

 

I agree that many systems have issues with S3 sleep mode.    Some of those work fine with S1, but there's no real reason not to simply use S5 ("Off")  :)

Link to comment

i only brought S3 into it because i feared that it would be a requirement for the scheduled shutdowns, but if you're telling me that it can be accomplished with an "S5" (didn't know that actually existed, or maybe you were being coy ;) ), then i'd be happy to figure that out.

 

i have never had to deal with cron jobs, so at the risk of getting some eye rolls: where do i even start to run a schedule to turn the machine OFF at certain hours? and what needs to work to allow it to be turned ON from being shut off?

Link to comment

i only brought S3 into it because i feared that it would be a requirement for the scheduled shutdowns, but if you're telling me that it can be accomplished with an "S5" (didn't know that actually existed, or maybe you were being coy ;) ), then i'd be happy to figure that out.

 

i have never had to deal with cron jobs, so at the risk of getting some eye rolls: where do i even start to run a schedule to turn the machine OFF at certain hours? and what needs to work to allow it to be turned ON from being shut off?

 

You will probably want the clean powerdown script from unmenu, and you will need to edit your go script to echo a power down command to the cron daemon, and will probably have to restart cron after that's done.  It's a lot of research to do, but maybe someone can help with it (I don't have access to my unRAID presently), but you should be able to find information by searching the forums.

 

You'll also need to find out if you can wake your device from sleep with a WOL agent.  There are various software implementations of this available on OS X, Windows and Linux. 

 

I'd start with determining if you can sleep/shutdown your unRAID server and start it back up with WOL.  If that doesn't work all the other steps are moot.

Link to comment

...  it can be accomplished with an "S5" (didn't know that actually existed, or maybe you were being coy ;) ), then i'd be happy to figure that out.

 

Nothing "coy" about it.  s5 = Off.    There are 5 defined power states:  s1, s2, and s3 are differing degrees of "sleep";  s4 is "hibernation" (off with a fully saved state written to disk);  and s5 is "Off".

 

Link to comment

i'm glad, garycase, and now i know :)

 

i was sucked into a small project (ongoing), which didn't allow me to get into the necessary research yet that sureguy suggested.

 

per your suggestion, i'll start by testing whether WOL will wake my server as needed...might have time for that part over the next day(s) and will report back once i have that part working, inshallah.

 

sounds like the steps after that will push me to the edges (and beyond) of my known universe ;)

Link to comment

I'll look into that possibility in my BIOS after i get back from voting, WeeboTech...thanks for that suggestion!

 

In the meantime i found a small $1.99 app called "Wake On Lan" (http://www.depicus.com/wake-on-lan/wake-on-lan-for-apple-mac.aspx) that i hope will make issuing and monitoring the Unraid server's wake-up a little easier for me...i know there are free command line tools available, but i figured "hey, why not?".

 

what is the proper syntax in telnet to get the server's MAC address?

 

gotta run to the polling place now, back at it later...

 

after a quick search in the wiki, it looks like "ifconfig" is the answer...will try later.

(not to myself: "search is your friend!")

Link to comment

aaaand BINGO!

 

works like a charm...if i do a clean Power-down of the Unraid server, then enter the MAC address, IP number, subnet and Port (7) into the Wake on LAN app, it starts up the Unraid as hoped :)

 

i wonder whether that might not be all i need for now...frankly, it's already lazy of me to not just roll my chair over to the server and do all of this manually, but i would like to be able to shut the server down when i work from Europe for weeks on end, and wake it up if i find that i need a few files, then shut it down again afterwards.

 

with that said, a clean power-down would be possible if i can telnet into the server from outside, right? i'll have to figure out how to do the IP and port forwarding in my router now anyway...if i can figure that out, i guess i don't really need the scheduled shutdowns/startups afterall, since i'd be doing this "on-demand", so to say  :-\

 

an initial search through the wiki did not find me the telnet command for a clean power-down yet...anyone?

 

as a matter of fact, i am apparently so rusty/unable with the command line that i can't even telnet into my Unraid server...i tried: telnet [email protected]

 

i'm embarrassed to ask, but what's the correct syntax for telnet'ing in and then doing a clean power-down?

 

Link to comment

 

$ telnet unraid

Trying 127.0.0.1...

Connected to unraid.

Escape character is '^]'.

 

unRAID login: root

Password: yourpassword

Linux 3.9.6p-unRAID.

 

root@unRAID:~# ls -l /usr/local/sbin/power*

-rwxr-xr-x 1 root root 393 2013-08-28 13:48 /usr/local/sbin/powerdown*

 

root@unRAID:~# cat /usr/local/sbin/powerdown

#!/bin/bash

#

# Helper script to gracefully power-down unRAID server.

# Works only if webGui is running and listening on port 80.

 

# Access a blank page in case this is first request since startup.

/usr/bin/wget -q -O - localhost/update.htm >/dev/null

 

# Have emhttp do all the work as if user clicked 'shutdown' in webGui.

/usr/bin/wget -q -O - localhost/update.htm?shutdown=apply >/dev/null

 

Link to comment

thanks WeeboTech!

 

well, i have WOL'ed and powerdown'ed the server a number of times since yesterday, and it works like a charm!

 

since this is of limited use while i am at my studio, the real advantage would come when/if i could do this remotely, while working from Europe or while on the road here in the USA, but my attempts to get through the router from the outside world have failed so far...i downloaded a couple of iPhone apps, added port forwarding to my router, confirmed that my dyndns setup is working properly, but when trying to reach the dyndns address and port, the attempts keep timing out...of course, i can Screen Share into my network from the outside world and then start a terminal on my iMac from which to do the same, but it is a bit kludgy of a solution.

 

wouldn't it be nice to have some sort of a combined WOL and Telnet app that could run powerdown, wakeup and reboot operations from the outside world!

 

but i guess that would be another topic, now, wouldn't it? i already deviated too much from the original intent of scheduled shutdowns, ending up at "manual remote powerdown and wakeup.

 

should i start a new topic for figuring out the router issue for WOL and Telnet? or is that not really something that should be discussed on the Unraid forums?

Link to comment

should i start a new topic for figuring out the router issue for WOL and Telnet? or is that not really something that should be discussed on the Unraid forums?

 

it's related to managing your unRAID server remotely. Others could possibly benefit from the information and discussion. I would suggest a new thread.

 

I would also suggest adding hyperlinks to each thread so people can understand the impetus and follow the whole discussion.

Link to comment

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...