Fireball3 Posted November 23, 2013 Share Posted November 23, 2013 If you have experience in scripting it would be nice if you take over the job. Perhaps you can check what's wrong with my attempt to check for a lock file? Quote Link to comment
peter_sm Posted November 23, 2013 Share Posted November 23, 2013 OK, I tried to implement the lockfile check but it throws some errors. ./auto_s3_sleep.sh: line 233: [: : integer expression expected ./auto_s3_sleep.sh: line 314: [: -eq: unary operator expected Can someone check where I messed it up? TRY ADD [[ ]] instead of [ ..... ] so these 2 line looks like this. if [[ "$hourMatch" -eq 0 -a "$LockFile" -eq 0]] if [[$LockFile -eq 1 ]] Why do you need a lock file? I have not follow all discussions .... //Peter Quote Link to comment
Fireball3 Posted November 23, 2013 Share Posted November 23, 2013 New result: ./auto_s3_sleep.sh: line 233: syntax error in conditional expression ./auto_s3_sleep.sh: line 233: syntax error near `-a' ./auto_s3_sleep.sh: line 233: ` if [[ "$hourMatch" -eq 0 -a "$LockFile" -eq 0 ]] I wonder why it's ok in line 272? if [ "$TCPact" -lt "$noTCP" -a "$SSHact" -eq 0 -a "$SHELLact" -eq 0 -a "$IPping" = $no ] Why a lock file: I tend to preclear drives in my server. This may get a bit tricky because this script won't consider other drives that are not part of unraid. Also for any other eventualities I didn't think of until now I would suggest to include one more constraint. Quote Link to comment
peter_sm Posted November 23, 2013 Share Posted November 23, 2013 please try this version, telnet added, and your error is gone, BUT I maybe done something wrong ;-) please check the code. i also think I made some changing on below line , see the red marking Lockfile='check_LockFile' if [ "$hourMatch" == 0 -a "$Lockfile" == 0 ] then //Peter auto_s3_sleep_work_TELNET.txt Quote Link to comment
peter_sm Posted November 23, 2013 Share Posted November 23, 2013 Why a lock file: I tend to preclear drives in my server. This may get a bit tricky because this script won't consider other drives that are not part of unraid. Also for any other eventualities I didn't think of until now I would suggest to include one more constraint. I have drives outside the array, if they are spinning , the server wont sleep. maybe THIS scrip ignore those drives I have a older S3 script than this you are working with (it's from the SF) and I also have worked on the server on a telnet session, and my server suddenly go to sleep therefore I need a telnet check to avoid sleeping when I log on to my server. Quote Link to comment
peter_sm Posted November 24, 2013 Share Posted November 24, 2013 s3 script from SF is attached, this one have a lot more settings than the script in this thread. //Peter s3_sleep.txt Quote Link to comment
Fireball3 Posted December 3, 2013 Share Posted December 3, 2013 please try this version, telnet added, and your error is gone, BUT I maybe done something wrong ;-) please check the code. i also think I made some changing on below line , see the red marking Lockfile='check_LockFile' if [ "$hourMatch" == 0 -a "$Lockfile" == 0 ] then //Peter Finally had some time to check your implementation but unfortunately... ./auto_s3_sleep.sh: line 247: syntax error in conditional expression ./auto_s3_sleep.sh: line 247: syntax error near `-a' ./auto_s3_sleep.sh: line 247: ` if [[ "$hourMatch" -eq 0 -a "$LockFile" -eq 0 ]]' Quote Link to comment
Fireball3 Posted December 10, 2013 Share Posted December 10, 2013 Somebody here who can adjust the syntax in this script please? Quote Link to comment
Carabolic Posted December 21, 2013 Share Posted December 21, 2013 Just upgraded from UnRAID v4.7 to v5.0.4 and so far had positive experience with this modified sleep script, which I used in v4.7: #!/bin/bash # Table of all possible drives when all drive slots are fully populated, with usb boot flash "/dev/sda" excluded drives="/dev/sdb /dev/sdc /dev/sdd /dev/sde /dev/sdf /dev/sdg /dev/sdh /dev/sdi /dev/sdj /dev/sdk /dev/sdl /dev/sdm /dev/sdn /dev/sdo" # Timeout in minutes timeout=60 count=$timeout 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 # Flush hdd filebuffers sync # Go to sleep echo -n mem > /sys/power/state # Do post-sleep activities # Flush hdd filebuffers sync # Force NIC into gigabit mode # (might be needed forgets about gigabit when it wakes up) ethtool -s eth0 speed 1000 # 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 Quote Link to comment
naxiand Posted January 3, 2014 Share Posted January 3, 2014 Do you have a sas card? It used to work for me also, but after I had add a sas card server could go to sleep but not wake up anymore... I haven't tried with 504 version of unraid which have recently upgrade it.... Sent from my Nexus 7 using Tapatalk 4 Quote Link to comment
Superorb Posted April 30, 2014 Share Posted April 30, 2014 What exactly does Carabolic's script do? I'm able to sleep the server with the "echo -n mem > /sys/power/state" command and wake via magic packet, but I don't like putting the server to sleep without first making sure nothing is running or being accessed, and I'd like the drives to be spun down before the server goes to sleep. Is this possible? I'm on 5.0 Final. Quote Link to comment
Fireball3 Posted June 4, 2014 Share Posted June 4, 2014 OK, with extensive help from WeeboTech I finally managed to get the auto_s3_sleep script working. Possible settings/checks: # check for TCP activity # check for any SSH connections # check for any TELNET connections # check for any locally logged in sessions (if "no" allows console debugging) # check for tmp/nos3sleep.lock (if this file exists, no sleep will be performed) # do not sleep if dedicated clients are pingable # only countdown outside specified hours # call smarthistory script to log SMART values before powerdown (not tested & not confirmed working) # choose between s3 sleep or powerdown (make sure you have installed the clean powerdown script) Rename the file to .sh Edit: attachment temporarily removed due to a reported minor bug (bug has been found, removed but remains to be confirmed) Quote Link to comment
Superorb Posted June 4, 2014 Share Posted June 4, 2014 Thanks for working on this Fireball. When I run the script it seems to just loop at this point. I have all checks set to "no" except for lock file and disks parked. No IP checks either. Wed Jun 4 09:59:35 MDT 2014: All HDDs spun down. Wed Jun 4 09:59:35 MDT 2014: Server is now idling. Checking for external activity. Wed Jun 4 09:59:35 MDT 2014: Checking for network activity. Wed Jun 4 09:59:35 MDT 2014: TCP activity (30 second average): 700 Wed Jun 4 09:59:35 MDT 2014: nobody online Wed Jun 4 09:59:35 MDT 2014: Active SSH connections: 0 Wed Jun 4 09:59:35 MDT 2014: Active TELNET connections: 0 Wed Jun 4 09:59:35 MDT 2014: Active console logins: 0 Quote Link to comment
Fireball3 Posted June 23, 2014 Share Posted June 23, 2014 Here is the version 1.1 of the auto_s3_sleep script. Thanks to Superorb who helped to get rid of some bugs. In the process I also made the logging more detailed. If the script runs for your satisfaction you may want to set the debug variable to 0 (no logging) to keep writes to the log (flash drive) as low as possible. Some answers to questions that arose: This script is only checking certain conditions and either shuts down the server or sends it to S3 sleep. Powerdown is done by invoking the /sbin/powerdown You should ensure that the clean powerdown script is installed, it is not part of this script! S3 sleep is done by echo -n mem > /sys/power/state It seems that sending the server to S3 sleep is not trivial though. unRAID will return many errors when waking up again. The whole extent is not clear since I don't use it. There should probably be some kind of routine to, at least, unmount the array before sleeping. More work and testing is needed so watch out when using S3! Possible settings/checks: # check for TCP activity # check for SSH connections # check for TELNET connections # check for locally logged in sessions # check for tmp/nos3sleep.lock (if this file exists, no sleep will be performed) # do not sleep if dedicated clients are pingable # only countdown outside specified hours # call smarthistory script to log SMART values before powerdown (not tested & not confirmed working) # choose between s3 sleep or powerdown (make sure you have installed the clean powerdown script) Rename the file to .sh Edit with a unix-like editor (e.g. notepad++) and configure to your needs. Update: Version 1.2 of this script is here It adds the possibility to exclude drives. Thanks go 2 maspiter. Quote Link to comment
Superorb Posted June 23, 2014 Share Posted June 23, 2014 Thanks Fireball, Auto Shutdown has been working great lately. Quote Link to comment
Mr_Gamecase Posted July 5, 2014 Share Posted July 5, 2014 Hi all, I cant seam to get S3 2 work properly .... i can invoke it ok but upon Wol wakeup all i get is a black screen nothing, no tel, webgui, avery , nada ? Any ideas ? Quote Link to comment
Fireball3 Posted July 7, 2014 Share Posted July 7, 2014 I remember having read similar issues somewhere in this forum - keep searching. It is not caused by the script - it's a general issue with S3 on your configuration. Quote Link to comment
dopray Posted July 18, 2014 Share Posted July 18, 2014 Hi all, I have the following question : I'm looking for the best way to run the following command each time my system runs : "ethtool -s eth wol g". If I run this manually I can perfectly WOL the next time but the time after that it has reset to "d". I've looked around the forums and tried several things : - added the command to my go script - tried to add it to the powerdown script (but possible didn't do it in the right place?) - added it to the sleep settings in Dynamix ("to Set WOL options before sleep:" , to "Custom commands before sleep:" and to "Custom commands after wake-up:" Can anyone point me to the best way to go to make sure "g" is activated before every shutdown or can this really only be done by running the command myself manually? Thanks in advance and sorry if I overlooked this somewhere on the forum but there is so much information here (spread over different versions of unRaid / scripts from the past) that I'm having a hard time finding the right solution. Quote Link to comment
peter_sm Posted July 18, 2014 Share Posted July 18, 2014 I have that as the last line in my go file Sent from my iPhone using Tapatalk 2 Quote Link to comment
dopray Posted July 18, 2014 Share Posted July 18, 2014 I have that as the last line in my go file I tried that, but didn't seem to work. Do I have to put another command in front of it (wait?) so it doesn't load too early or isn't that possible? Quote Link to comment
maspiter Posted August 24, 2014 Share Posted August 24, 2014 @Fireball3 Thanks for your script, I'm currently using it because the Dynamix script doesn't seem to take network activity into account. I have a suggestion though. Since I'm still using the free version and use a drive outside the array to host some apps, it might be a good idea to add in support to exclude a drive. I added a $nonArrayDisk variable myself and added an extra "| grep -v $nonArrayDisk" to filter it out the check_HDD_activity() but there is probably a more elegant way to do this. I also noticed a comment regarding checking for a cache drive but no commands are actually in place I think? @dopray You can try adding it to the section pre_sleep_activity or post_sleep_activity in the script on the previous page. If it is working with that script, the Dynamix script might not execute your settings in the webGUI. Have you checked this with a trivial command like creating a file i.e. and after wake-up check whether it is actually created? Hi all, I cant seam to get S3 2 work properly .... i can invoke it ok but upon Wol wakeup all i get is a black screen nothing, no tel, webgui, avery , nada ? Any ideas ? I had the same problem. Tested a full Slackware install on the same system and sleep worked fine so it was not a hardware problem. Tried many different things but in the end compiled my own custom kernel with added drivers for my AMD GPU. Since then, it sleeps and wakes just fine. It's a lot of work, certainly since you have to redo it each time you want to upgrade but IMO it's worth it. There's a guide in the wiki on compiling a custom kernel, one of my earlier posts also links to references I used. Hope this helps. Quote Link to comment
thica Posted August 25, 2014 Share Posted August 25, 2014 Hallo, sound promising. Are you willing to share your binaries? Quote Link to comment
Fireball3 Posted August 25, 2014 Share Posted August 25, 2014 @Fireball3 Thanks for your script, I'm currently using it because the Dynamix script doesn't seem to take network activity into account. I have a suggestion though. Since I'm still using the free version and use a drive outside the array to host some apps, it might be a good idea to add in support to exclude a drive. I added a $nonArrayDisk variable myself and added an extra "| grep -v $nonArrayDisk" to filter it out the check_HDD_activity() but there is probably a more elegant way to do this. I also noticed a comment regarding checking for a cache drive but no commands are actually in place I think? Thanks for improving! Please document/comment the changes inside the script, raise the version number and then post it here. I'm far from being that experienced to tell if there are better ways of scripting - if it works it's OK. Maybe others, with the same use case, will want to test and comment on it? Quote Link to comment
maspiter Posted August 25, 2014 Share Posted August 25, 2014 Ok, I added in my changes. I also took the liberty to move the configuration section to the top and moved the $noTCP and $debug variables to the configuration section for ease of use and added a few comments about determining which value to use for $noTCP for your specific system/use case. They might be obvious but thought I'd add them anyway. Hallo, sound promising. Are you willing to share your binaries? You talking to me? If you're asking about the custom kernel, then sure, I am willing to share. Except I doubt it will do you any good because I only added in the firmware for my specific GPU (HD6310). I guess it should work for HD6250, HD7310 and HD7340 too (according to the method I used, https://wiki.gentoo.org/wiki/Radeon#External_resources) but these are all notebook GPUs. But, I am by no means an unRAID nor linux expert. I just happen to have just enough knowledge to follow a few guides here and there. On top of that, my bzroot is smaller than the stock one because I stripped out some stuff I don't need, mostly drivers for ethernet cards I am not using I believe. That means your ethernet will probably only work when using a Realtek (I know) card. So, as a disclaimer, using my files is at your own risk. I cannot be held responsible for data loss or any other unfortunate events that may or may not be tied to using them. etc etc ... That said, I've had no issues so far and recently even replaced a disk with a larger one flawlessly. If you're still interested send me a PM with your email or something because one file is too big to post on the forum. EDIT 1: I might have another version with all the drivers included. It is twice the size of the stock version though. You can add them to the syslinux.cfg file but better keep the stock as default. This way you can reboot and test it out without committing. Used this one for a bit but compiled another one afterwards apparently. When I have some time I'm going to redo the whole process and maybe put a more descriptive guide online if there is some interest. The wiki article is a bit basic I think. EDIT 2: I uploaded the files so others might benefit without having to contact me, don't know how long these will be available though. Unraid 5.0.5 with radeon HD6310 and some drivers removed (what I'm using now): http://www.files.com/set/53fcda459510f Unraid 5.0.5 with radeon HD6310 and stock drivers: http://www.files.com/set/53fcddb19096c I'm using an E35M1-I BTW. auto_s3_sleep.txt Quote Link to comment
EdgarWallace Posted October 12, 2014 Share Posted October 12, 2014 I'm trying to send my Test&Backup unRAID Server to sleep so that I can easily wake it up once a day when a backup is needed. Luckily I can send the system to sleep: echo -n mem > /sys/power/state and everything's running fine again when I'm sending a wol package. However the script (thanks to those who developed this) doesn't send the server to sleep: Sun Oct 12 18:41:21 CEST 2014: HDD activity detected. Active HDDs: 1 Sun Oct 12 18:42:21 CEST 2014: No lock file detected and time of day allows countdown for S3/powerdown. Sun Oct 12 18:42:21 CEST 2014: HDD activity detected. Active HDDs: 1 Sun Oct 12 18:46:29 CEST 2014: No lock file detected and time of day allows countdown for S3/powerdown. Sun Oct 12 18:46:29 CEST 2014: HDD activity detected. Active HDDs: 5 Sun Oct 12 18:47:29 CEST 2014: No lock file detected and time of day allows countdown for S3/powerdown. Sun Oct 12 18:47:29 CEST 2014: HDD activity detected. Active HDDs: 5 Sun Oct 12 18:48:29 CEST 2014: No lock file detected and time of day allows countdown for S3/powerdown. Sun Oct 12 18:48:29 CEST 2014: HDD activity detected. Active HDDs: 5 Sun Oct 12 18:49:29 CEST 2014: No lock file detected and time of day allows countdown for S3/powerdown. Sun Oct 12 18:49:29 CEST 2014: HDD activity detected. Active HDDs: 5 Sun Oct 12 18:50:29 CEST 2014: No lock file detected and time of day allows countdown for S3/powerdown. Sun Oct 12 18:50:29 CEST 2014: HDD activity detected. Active HDDs: 5 Sun Oct 12 18:51:29 CEST 2014: No lock file detected and time of day allows countdown for S3/powerdown. Sun Oct 12 18:51:30 CEST 2014: HDD activity detected. Active HDDs: 5 Sun Oct 12 18:52:30 CEST 2014: No lock file detected and time of day allows countdown for S3/powerdown. Sun Oct 12 18:52:30 CEST 2014: HDD activity detected. Active HDDs: 5 Sun Oct 12 18:53:30 CEST 2014: No lock file detected and time of day allows countdown for S3/powerdown. Sun Oct 12 18:53:30 CEST 2014: HDD activity detected. Active HDDs: 5 Sun Oct 12 18:53:55 CEST 2014: Sun Oct 12 18:53:55 CEST 2014: Start checking conditions for standby... Sun Oct 12 18:53:55 CEST 2014: No lock file detected and time of day allows countdown for S3/powerdown. Sun Oct 12 18:53:55 CEST 2014: HDD activity detected. Active HDDs: 5 Sun Oct 12 18:54:30 CEST 2014: No lock file detected and time of day allows countdown for S3/powerdown. Sun Oct 12 18:54:30 CEST 2014: HDD activity detected. Active HDDs: 5 ...and some more information: Oct 12 18:53:55 Tower2 auto_s3_sleep: ----------- auto_s3_sleep version 1.2 --------------------- Oct 12 18:53:55 Tower2 auto_s3_sleep: Configuration settings: Oct 12 18:53:55 Tower2 auto_s3_sleep: Power down instead of sleep: no Oct 12 18:53:55 Tower2 auto_s3_sleep: Check HDD activity: yes Oct 12 18:53:55 Tower2 auto_s3_sleep: Check TCP activity: yes Oct 12 18:53:55 Tower2 auto_s3_sleep: Check SSH connections: yes Oct 12 18:53:55 Tower2 auto_s3_sleep: Check TELNET connections: yes Oct 12 18:53:55 Tower2 auto_s3_sleep: Check for online clients: Oct 12 18:53:55 Tower2 auto_s3_sleep: Check local logins: yes Oct 12 18:53:55 Tower2 auto_s3_sleep: Check for lock file (tmp/nos3sleep.lock): yes Oct 12 18:53:55 Tower2 auto_s3_sleep: No sleep/powerdown during hours: Oct 12 18:53:55 Tower2 auto_s3_sleep: Save SMART values before powerdown: no Oct 12 18:53:55 Tower2 auto_s3_sleep: Log message destination: /boot/logs/auto_s3_sleep.log Oct 12 18:53:55 Tower2 auto_s3_sleep: --- After wake up from sleep: ---- Oct 12 18:53:55 Tower2 auto_s3_sleep: Renew DHCP: yes Oct 12 18:53:55 Tower2 auto_s3_sleep: Force GB LAN: yes Oct 12 18:53:55 Tower2 auto_s3_sleep: ------------------------------------------------------------ Even if all HDDs are spun down the server is still active. There is no VM & any Docker active. The only change I made in the script is the following (I thought that the SSD cache drive should be excluded from the HDD activity check: # uncomment the following variable to ignore one or more disks in check_HDD_activity() singular example: nonArrayDisk="/dev/sdb" Any ideas where to look at? Thanks a lot in advance. 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.