optimus24 Posted January 20, 2011 Share Posted January 20, 2011 Hi there. Another question from a new owner. Have been trying to get my machine to S3 sleep automatically. I am using the latest version on this thread and doesn't seem to work. I trying it even without checking IPs and have manually spundown to drives to see if the script would sleep my machine. But no such luck. I can successfully sleep by the sleep user script and resume by magic packet. Script is running and seemingly w/o error. Was looking at the place in the script where it check for active drives. to prevent probing of the flash drive. and my drives dont say "flash" anywhere when i run those commands in a telnet window. since the script seems to work for everyone was wondering where i can look to fix this. Thanks Quote Link to comment
spl147 Posted February 1, 2011 Share Posted February 1, 2011 i tried the latest script in this post for s3 suspend it does put my box to sleep.....but when i wake it up i have no video and nic does not respond.....i must reboot to regain control.......motherboard is a supermicro x7spa-hf Quote Link to comment
lewcass Posted February 1, 2011 Share Posted February 1, 2011 i tried the latest script in this post for s3 suspend it does put my box to sleep.....but when i wake it up i have no video and nic does not respond.....i must reboot to regain control.......motherboard is a supermicro x7spa-hf You'll probably need to use s2ram to restore your video and nic states. There are plenty of posts throughout this thread on this issue. Search for s2ram to read them all but best place to start may be here with bubbaQ'a very helpful download: http://lime-technology.com/forum/index.php?topic=3657.msg70945;topicseen#msg70945 Quote Link to comment
jonlai9 Posted March 11, 2011 Share Posted March 11, 2011 I didn't read the entire thread but.. is there a way to wake up the server without using a batch file, but rather from just accessing the network share in Windows? I have them all mapped. Quote Link to comment
Joe L. Posted March 11, 2011 Share Posted March 11, 2011 I didn't read the entire thread but.. is there a way to wake up the server without using a batch file, but rather from just accessing the network share in Windows? I have them all mapped. Short answer, probably not. Quote Link to comment
jonlai9 Posted March 11, 2011 Share Posted March 11, 2011 When the magic packet is sent using the batch file, do all the drives in the array spin up? Is there a way to just wake the server without spinning up all disks until they are each accessed individually? Thanks. Quote Link to comment
jonlai9 Posted March 11, 2011 Share Posted March 11, 2011 Here's an updated version -- this one you'd have to background from the go script rather than cron-launch. It has a 15 minute (programmable) countdown from spindown to sleep. While the old one wouldn't corrupt anything, I feel its control mechanism is pretty clutzy - you could get weird cases where upon wakeup it might immediately re-sleep if the drives didn't spin up. Or you hit the spindown button on the gui and shortly after the whole thing shuts down. Now the time intervals are tightly tied together and more predictable for the user: EDIT: Threw in a dchp lease-renewal - my router box seems to forget about the lease (expires) and it doesn't seem like I'm getting an immediate renewal upon wakeup if the lease expired. This rectifies the situation #!/bin/bash drives="/dev/hda /dev/hdb /dev/sda /dev/sdb" timeout=15 count=15 while [ 1 ] do hdparm -C $drives | grep -q active if [ $? -eq 1 ] then count=$[$count-1] else count=$timeout fi if [ $count -le 0 ] then # Do pre-sleep activities sleep 5 # Go to sleep echo 3 > /proc/acpi/sleep # Do post-sleep activities # Force a DHCP renewal (shouldn't be used for static-ip boxes) /sbin/dhcpcd -n sleep 5 count=$timeout fi # Wait a minute echo COUNT $count sleep 60 done Just add this to the 'go' script and it should sleep 15 minutes after all drives are spun down right? /boot/custom/bin/s3.sh Just wondering: This script doesn't seem to stop the array, just wait for all drives to be spun down, and then sleep. Does the array need to be stopped before sleeping? Edit: I just did some testing by running echo 3 > /proc/acpi/sleep on the prompt. I stopped the array before sleeping, and I noticed that when I wake the server is stopped. Was I supposed to not have stopped the server before sleeping? Would that have made the server remain started when I wake on LAN? I just felt it made sense that everything should be stopped before sleeping, since it's pretty much similar to shutting down the server. Thanks. Quote Link to comment
lewcass Posted March 11, 2011 Share Posted March 11, 2011 You should not stop the array before suspending. Yes. All drives will wake up when the server does. No. Windows is not smart enough to send a wake-on-LAN instruction to a sleeping attached network drive. You have to do it manually. Be nice if Microsoft had thought of that though. Might want to suggest it to them. Much more useful than, for example, their lame feature that increases the size of Windows you move to the edge of the screen. Quote Link to comment
jonlai9 Posted March 12, 2011 Share Posted March 12, 2011 I've attached an updated version of the sleep script. The main aim was to repackage the various bits of functionality that different people have proposed already. There's little new functionality, but everything has been nicely parameterized for easy configuration. It should also be easy to re-code the various activity checks. The central logic of the script is that countdown to server sleep proceeds in three consecutive steps 0) unRAID puts the HDDs to sleep, absent access to their (uncached) content 1) a timeout after last HDD goes to sleep [original sleep counter] 2) a timeout after last external activity, currently * TCP access over some 30sec window within the current 1-minute countdown tick * ping of specific IP addresses, to ascertain whether media players, etc., are online -) the countdown may be suspended altogether at certain hours. If any previously timed-out conditions are re-activated, subsequent time-out counters are reset. The attached script should make it straightforward to configure whether and how to do each of these and for how long, and whether to re-new DHCP and re-negotiate for a gigabit connection upon wake-up, and more. Can someone give me a step by step instructions on how to install s2ram and what to edit in this script file and in my 'go' script to work with s2ram? Thanks. Quote Link to comment
darkside40 Posted May 13, 2011 Share Posted May 13, 2011 I just installed 5.0-beta6a with the s3.sh. I dont need s2ram because my Mobo doesn't has any issues. The only thing is that the script i use here normally uses s2ram to let the server go to S3. Now i tried to change that to echo 3 > /proc/acpi/sleep, but this does not exist. What i found what works is echo "mem" /sys/power/state, is that the right line to power down my unRaid server? The script would look like this (Line 145 chnaged) #!/bin/bash # constants yes="yes" no="no" # [CONFIGURATION] # before going to sleep intrnlTimeoutTicks=2 # ticks after HDD spindown before checking for external activity extrnlTimeoutTicks=1 # ticks of no external activity before sleep; only after spindown+internal countdown # control of internal timeout checkHDDs=$yes # check if all HDDs are parked before counting down towards sleep noCountdownHours="" # only countdown towards sleep outside these hours # example: <noCountdownHours="07 08 19 20"> # always countdown: <noCountdownHours=""> # control of external timeout checkTCP=$no # check for TCP activity pingIPs="" # do not sleep if <$pingsIPs> are pingable # example: <pingIPs="192.168.1.4 192.168.1.5"> # no ping-check: <pingIPs=""> # after waking up from sleep doDhcpRenewal=$no # <$no> for servers w/static IP address forceGb=$yes # might not be needed; probably always safe # [/CONFIGURATION] # implementation stuff ticklengthSecs=60 # probe hardware + count down every minute/60secs, aka a tick noTCP='0.00' # what constitutes absence of TCP activity flash=/dev/`ls -l /dev/disk/by-label| grep UNRAID | cut -d"/" -f3 | cut -c 1-3` # automatic id of flash drive check_hour() { echo $(date +%H) } check_HDD_activity() { if [ $checkHDDs = $yes ] then # probe the flash drive at your peril HDDs=$((for d in $(ls /dev/[hs]d? | grep -v "$flash"); do hdparm -C $d | grep active ; done) | wc -l) else HDDs=0 fi echo $HDDs } check_TCP_activity() { if [ "$checkTCP" = $yes ] then TCP=$(bwm-ng -o csv -c 1 -d 0 -T avg | grep eth0 | cut -d";" -f5) else TCP="$noTCP" fi echo "$TCP" } check_IP_status() { mp_online=$no # initialize to "no" until we learn otherwise # ping each of the media servers to determine if online for i in $pingIPs do # ping the media server; if it answers, it is online out=`ping -q -c 1 $i 2>/dev/null` rec_count=`echo "$out" | grep received | cut -d " " -f4` if [ "$rec_count" -eq 1 ] then mp_online=$yes # if one is online, we do not need to ping # any others, break out of the "for" loop. break; fi done echo $mp_online } pre_sleep_activity() { /usr/local/sbin/mover echo $(date) Mover Complete sleep 5 /bin/sync echo $(date) Sync Complete } post_sleep_activity() { echo $(date) Resumed from sleep # Force NIC to use gigabit networking if [ "$forceGb" = $yes ] then ethtool -s eth0 speed 1000 echo $(date) Network set to Gb fi # Force a DHCP renewal (shouldn't be used for static-ip boxes) if [ "$doDhcpRenewal" = $yes ] then /sbin/dhcpcd -n fi echo $(date) unRAID Server Online } # main echo $(date) Starting S3 script intrnlCountdown=$intrnlTimeoutTicks extrnlCountdown=$extrnlTimeoutTicks while [ 1 ] do # do not countdown during certain hours hour=`check_hour` hourMatch=$(echo "$noCountdownHours" | grep "$hour" | wc -l) if [ $hourMatch -eq 0 ] then # count number of HDDs that are not parked HDDact=`check_HDD_activity` if [ "$HDDact" -eq 0 ] then # tick-tock for time since last spindown if [ $intrnlCountdown -gt 0 ] then intrnlCountdown=$[$intrnlCountdown-1] fi else # reset countdown, following HDD activity intrnlCountdown=$intrnlTimeoutTicks extrnlCountdown=$extrnlTimeoutTicks fi if [ $intrnlCountdown -le 0 ] then # check for persistent external activity TCPact=`check_TCP_activity` IPping=`check_IP_status` if [ "$TCPact" = $noTCP -a "$IPping" = $no ] then if [ $extrnlCountdown -le 0 ] then # Do pre-sleep activities pre_sleep_activity sleep 5 # Go to sleep echo $(date) Going to sleep NOW! echo $(date) unRAID Server Offline echo "mem" > /sys/power/state # Do post-sleep activities post_sleep_activity sleep 5 intrnlCountdown=$intrnlTimeoutTicks extrnlCountdown=$extrnlTimeoutTicks else # tick-tock for persistent external activity if [ $extrnlCountdown -gt 0 ] then extrnlCountdown=$[$extrnlCountdown-1] fi fi else # reset countdown, following external activity extrnlCountdown=$extrnlTimeoutTicks fi fi fi # Wait a tick sleep $ticklengthSecs done Quote Link to comment
pan!c Posted June 2, 2011 Share Posted June 2, 2011 Hi, I currently use this script as intended to put my server to sleep after all clients are not pingable (shutdown). Is there a way to shutdown/powerdown the server instead? Do I need the powerdown package for this? Or do I just have to change the following line? echo 3 > /proc/acpi/sleep And change with which command? Thanks pan!c Quote Link to comment
darkside40 Posted June 2, 2011 Share Posted June 2, 2011 Like mentioned in my last post, take: echo "mem" > /sys/power/state Quote Link to comment
mrklaw Posted June 3, 2011 Share Posted June 3, 2011 do I need to shut down running apps like sabnzbd/sickbeard/minecraft before sleeping? can I call a script from sabnzbd when it has an empty queue? Here are my situations I want to try and cover: 1) wake up on a schedule so my kids can play minecraft and sabnzbd/sickbeard can check for new items. eg wake up around 4pm. Then sleep at midnight if drives are all idle and sabnzbd queue is empty. Otherwise delay until they are. Alternatively I could make them run a simple script (double click an icon, all the same to them) to wake it up on the days they are playing. 2) wake up from OSX for backups. I use chronosync with the NAS run weekly for backing up my mac mini and MBP overnight. If necessary I could edit a schedule on the unraid to sync the timings so it is awake, but chronosync can run commands before backup, so might be able to wake it up? Then sleep it afterwards. 3) wake up from plex. Don't know if this is possible but other than minecraft, the main use is media streaming, and I don't need that every day. Is there some way to issue a WOL command when trying to play a video from plex? If not I could run something from my ipad/ipod touch like a bookmark to initiate a script but not ideal. Not sure if its best for me to simply set up a window where its awake eg 4pm-midnight every day, and then on weekends (when I run my backups) keep it awake until 3am. But I'd still want to keep it awake in case of sabnzbd downloading. Quote Link to comment
skank Posted June 15, 2011 Share Posted June 15, 2011 Hi I'm using unraid v4.6 I'm currently using the clean powerdown script to powerdown, but i want to be able to let the server sleep. -Either by pushing the button on the case. -Giving a command from my pc upstairs, to let the server sleep... I can do this already by using putty and typing echo 3>/proc/acpi/sleep but there should be another way Also: Is going to sleep the same as the clean powerdown addon? When sleeping and waking up (waking already works) , does it make all hdd's spin up? or do they remain spinned down until you call them... Quote Link to comment
astranger Posted June 29, 2011 Share Posted June 29, 2011 You guys have done a pretty good job with the sleep script. On the waking up front I am looking at modifying this code to run on my router, pfSense. This script is intended for DD-WRT based routers. It waits for a request to an ip:port combo. In this example a request to IP 192.168.1.101 on port 80 will cause the script to run. The script pings 192.168.1.101, if no reply then it sends WOL. To adapt this for CIFS (SMB) use port 445 and the IP of the unRaid server. Issues I see up front are the timeout of CIFS before unRAID can respond and if the HTPC has already resolved the MAC of the unRaid system. Not sure what to do other then try it. If the MAC has already been resolved by the HTPC then a request may never go to the router triggering a WOL. WORKAROUND: Place a DD-WRT router between HTPC (main network) and unRAID. Downside might be serious bandwidth limitations depending on the DD-WRT hardware and another point of complexity. On the upside I could have added security protecting my file server. If unRAID does not respond before the CIFS timeout then just try again. I host a couple of other services on my unraid box so if I can get this working for CIFS then everything else should be a breeze. If I get this working I can post walk through. For the standby scripting, any plan to create an unMenu package? From: http://www.dd-wrt.com/wiki/index.php/Useful_Scripts#Web_Server_Wake-up #!/bin/sh #Enable JFFS2 and place script in /jffs/ then run on startup in web interface. #You can check the log from http://192.168.1.1/user/wol.html INTERVAL=5 NUMP=3 OLD="" PORT=80 WOLPORT=9 TARGET=192.168.1.101 BROADCAST=192.168.1.255 MAC=00:11:22:33:44:55 WOL=/usr/sbin/wol LOGFILE="/tmp/www/wol.html" echo "<meta http-equiv=\"refresh\" content=\"10\">" > $LOGFILE echo "AUTO WOL Script started at" `date` "<br>" >> $LOGFILE while sleep $INTERVAL;do NEW=`dmesg | awk '/ACCEPT/ && /DST='"$TARGET"'/ && /DPT='"$PORT"'/ {print }' | tail -1` SRC=`dmesg | awk -F'[=| ]' '/ACCEPT/ && /DST='"$TARGET"'/ && /DPT='"$PORT"'/ {print $7}' | tail -1` LINE=`dmesg | awk '/ACCEPT/ && /DST='"$TARGET"'/ && /DPT='"$PORT"'/'` if [ "$NEW" != "" -a "$NEW" != "$OLD" ]; then if ping -qc $NUMP $TARGET >/dev/null; then echo "NOWAKE $TARGET was accessed by $SRC and is already alive at" `date` "<br>">> $LOGFILE else echo "WAKE $SRC causes wake on lan at" `date` "<br>">> $LOGFILE $WOL -i $BROADCAST -p $WOLPORT $MAC >> $LOGFILE echo "<br>" >> $LOGFILE sleep 5 fi OLD=$NEW fi done Quote Link to comment
darkside40 Posted July 1, 2011 Share Posted July 1, 2011 Hi Guys, does anybody has a working solution to spinup the Data Disk's after S3? I tried it by integrating the mdcmd command into the script but it is not working really reliable. Quote Link to comment
skank Posted July 1, 2011 Share Posted July 1, 2011 Anyone willing to help me here, to put it too sleep, even from another pc Quote Link to comment
darkside40 Posted July 1, 2011 Share Posted July 1, 2011 Maybe using Livehttp Headers to record the WebGUI Commands to sleep the Server, extract the commands and than using a curl batch or script to sleep the server. Quote Link to comment
Joe L. Posted July 1, 2011 Share Posted July 1, 2011 Maybe using Livehttp Headers to record the WebGUI Commands to sleep the Server, extract the commands and than using a curl batch or script to sleep the server. Instead of pleading to others, and complaining about how their attempt to help you does not work with your brain-damaged media player, I strongly suggest you look at the existing suggestions, learn a tiny bit about linux shell, enough to put a program in the background, and make it work yourself. The formula for success seems to be a way to not go to sleep while your external device is waiting for a response, but at a time soon thereafter. Use the "at" comand Create your own user-script. (should take about 4 lines of script) It should basically say echo "echo 3 >/proc/acpi/sleep" | at now + 1 minute Or as an alternative: putting commands in the background echo "going to sleep" ( shell commands go here to put server to sleep and subsequently restore it when woken ) >/dev/null 2>&1 & Then, invoke YOUR new user-script, which puts the server to sleep. Quote Link to comment
jupilerman Posted July 2, 2011 Share Posted July 2, 2011 Anyone willing to help me here, to put it too sleep, even from another pc Install openssh on your unraid (unmenu can do it for you) For windows, get plink.exe and put it anywhere (i did it on my desktop) Create a bat file (named sleepunraid.bat or whatever) witch content is: cd C:\pathtowhereplinkis plink.exe -ssh 192.168.xxx.xxx -l root -pw unraidpassword "echo 3 > /proc/acpi/sleep" ; \ If your unraid is not password protected, then it could also work with telnet (no ssh and no plink needed) telnet 192.168.xxx.xxx -l root "echo 3 > /proc/acpi/sleep" ; \ or just open a telnet session and pass the command. Quote Link to comment
pan!c Posted July 6, 2011 Share Posted July 6, 2011 Hi, trying to replace sleep with shutdown I have a working sleep script (as described in this thread) and want to replace the sleep comand with a shutdown comand. I tried what darkside40 suggested and replace echo 3 > /proc/acpi/sleep with echo "mem" > /sys/power/state but this sets my server to sleep, too. The I installed unmenu and the power down package (which is also working if executed manually "/sbin/powerdown") But replacing echo 3 > /proc/acpi/sleep with echo 3 > /sbin/powerdown does not work either. I can hear the server "beep" and then nothing happens... Quote Link to comment
darkside40 Posted July 6, 2011 Share Posted July 6, 2011 Hi, trying to replace sleep with shutdown I have a working sleep script (as described in this thread) and want to replace the sleep comand with a shutdown comand. I tried what darkside40 suggested and replace echo 3 > /proc/acpi/sleep with echo "mem" > /sys/power/state but this sets my server to sleep, too. The I installed unmenu and the power down package (which is also working if executed manually "/sbin/powerdown") But replacing echo 3 > /proc/acpi/sleep with echo 3 > /sbin/powerdown does not work either. I can hear the server "beep" and then nothing happens... I have not tried this! Try echo "standby" > /sys/power/state I have this from this page here http://acpi.sourceforge.net/documentation/sleep.html that should send your server to Softoff (hopefully) Quote Link to comment
skank Posted July 9, 2011 Share Posted July 9, 2011 Anyone willing to help me here, to put it too sleep, even from another pc Install openssh on your unraid (unmenu can do it for you) For windows, get plink.exe and put it anywhere (i did it on my desktop) Create a bat file (named sleepunraid.bat or whatever) witch content is: cd C:\pathtowhereplinkis plink.exe -ssh 192.168.xxx.xxx -l root -pw unraidpassword "echo 3 > /proc/acpi/sleep" ; \ If your unraid is not password protected, then it could also work with telnet (no ssh and no plink needed) telnet 192.168.xxx.xxx -l root "echo 3 > /proc/acpi/sleep" ; \ or just open a telnet session and pass the command. great ! Will try that when i get home, thx in advance ! Quote Link to comment
skank Posted July 11, 2011 Share Posted July 11, 2011 i tried using plink i get C:\Program Files\Plink>cd C:\Program Files\Plink\ C:\Program Files\Plink>plink.exe -ssh 192.168.0.117 -l root "echo 3 > /proc/acpi /sleep" ; \ The server's host key is not cached in the registry. You have no guarantee that the server is the computer you think it is. The server's rsa2 key fingerprint is: ssh-rsa 2048 75:52:1e:65:d1:3e:bd:18:99:f3:6d:32:04:bf:67:29 If you trust this host, enter "y" to add the key to PuTTY's cache and carry on connecting. If you want to carry on connecting just once, without adding the key to the cache, enter "n". If you do not trust this host, press Return to abandon the connection. Store key in cache? (y/n) dont know what i should say, i'm sure ipadress is correct - i tried creating a bat file containing telnet 192.168.xxx.xxx -l root "echo 3 > /proc/acpi/sleep" ; \ it doesnt work - i tried opening telnet session and typing echo 3 > /proc/acpi/sleep this does work how do i get it now without doing it manually (going into putty) i just want a shortcut 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.