ralphbecket Posted May 4, 2016 Share Posted May 4, 2016 Hi, I'm running an up-to-date version of unRAID (6.1.9, I believe), I have installed the Dynamix Sleep plugin, and I have enabled wake-on-lan on the motherboard. My unRAID machine will now happily sleep after the disks spin down (per the Sleep plugin schedule) or if I use the 'Sleep' button from the web UI. WoL is working perfectly. What I haven't fathomed yet, is how to schedule the machine to wake up for various maintenance (e.g., I would like my Plex server to update the libraries every day at 3 AM -- but this currently won't happen when the machine is asleep). I could set up a scheduled task on one of my Windows boxes to send the WoL command, but it seems rather inelegant to have to schedule one PC just to wake up another PC! Can anyone offer some advice here as to how to make my unRAID machine wake up for maintenance at a given time every day? Many thanks! Quote Link to comment
JonathanM Posted May 4, 2016 Share Posted May 4, 2016 Wake at a specific time is typically enabled and configured in the BIOS, look for alarm or wake settings. Quote Link to comment
ralphbecket Posted May 4, 2016 Author Share Posted May 4, 2016 Thanks, but surely there must be some way of doing this at the OS level? Windows does this just fine. I really don't want to have to reboot every time I have to change the wake settings. Quote Link to comment
Paul_Ber Posted May 4, 2016 Share Posted May 4, 2016 What about wake on LAN for a Windows 7 VM? Sent from my XT1563 using Tapatalk Quote Link to comment
primeval_god Posted May 4, 2016 Share Posted May 4, 2016 You are looking for something along the lines of this, https://www.linux.com/learn/wake-linux-rtc-alarm-clock You can set an rtc alarm in the before sleep actions in the S3sleep plugin. That is assuming your hardware supports it. Quote Link to comment
ralphbecket Posted May 5, 2016 Author Share Posted May 5, 2016 I'm embarrassed to say I found the "excluded hours" option for the Sleep plugin; this seems to do just what I want, waking the computer during the hours specified. Thanks everyone for your suggestions. Quote Link to comment
feraay Posted February 13, 2017 Share Posted February 13, 2017 (edited) This Script should do it. Just paste it into S3 Sleep settings in the custom command box (post sleep) Be sure you disabled resume by rtc alarm in bios and set the bios time to rtc time. It will wakeup every day at 09.55. So you can set jobs for 10.00. time=09:55 now=$(date +%s) other=$(date -d $time +%s) if [ $now -ge $other ] then echo `date '+%s' --date='tomorrow 09:55:00'` > /sys/class/rtc/rtc0/wakealarm else echo `date '+%s' --date='today 09:55:00'` > /sys/class/rtc/rtc0/wakealarm fi Monday to Friday exclude Saturday and Sunday: time=09:55 now=$(date +%s) other=$(date -d $time +%s) dayofweek=$(date +%u) if [ $now -ge $other ] && [ $dayofweek -lt 5 ] then echo `date '+%s' --date='tomorrow 09:55:00'` > /sys/class/rtc/rtc0/wakealarm elif [ $dayofweek -ge 5 ] then echo `date '+%s' --date='next monday 09:55:00'` > /sys/class/rtc/rtc0/wakealarm else echo `date '+%s' --date='today 09:55:00'` > /sys/class/rtc/rtc0/wakealarm fi Edited April 7, 2018 by feraay 1 Quote Link to comment
king79 Posted November 11, 2017 Share Posted November 11, 2017 Hello, the script works great. Unfortunately, Unraid does not wake up on the weekend. How should the script be changed to achieve this? Quote Link to comment
feraay Posted April 7, 2018 Share Posted April 7, 2018 (edited) sorry for late answer. so you want the server to wake up every day at the same time? time=09:55 now=$(date +%s) other=$(date -d $time +%s) if [ $now -ge $other ] then echo `date '+%s' --date='tomorrow 09:55:00'` > /sys/class/rtc/rtc0/wakealarm else echo `date '+%s' --date='today 09:55:00'` > /sys/class/rtc/rtc0/wakealarm fi to be honest the better way to do it is set a alarm in bios and repeat every day. the script is only needed if you don't want the server to wake up every day. Edited April 7, 2018 by feraay Quote Link to comment
n3ro365 Posted June 12, 2019 Share Posted June 12, 2019 On 4/7/2018 at 11:43 AM, feraay said: sorry for late answer. so you want the server to wake up every day at the same time? time=09:55 now=$(date +%s) other=$(date -d $time +%s) if [ $now -ge $other ] then echo `date '+%s' --date='tomorrow 09:55:00'` > /sys/class/rtc/rtc0/wakealarm else echo `date '+%s' --date='today 09:55:00'` > /sys/class/rtc/rtc0/wakealarm fi to be honest the better way to do it is set a alarm in bios and repeat every day. the script is only needed if you don't want the server to wake up every day. Hi. I would like to wake up my unraid every day. This is my script: time=08:00 now=$(date +%s) other=$(date -d $time +%s) if [ $now -ge $other ] then echo `date '+%s' --date='tomorrow 08:00:00'` > /sys/class/rtc/rtc0/wakealarm else echo `date '+%s' --date='today 08:00:00'` > /sys/class/rtc/rtc0/wakealarm fi It always works only on the first day. On the 2nd day the server stays in sleep mode. It seems that the alarm is not reset. Can somebody help me with it? Thank you. Quote Link to comment
Kazino43 Posted January 28, 2020 Share Posted January 28, 2020 Although last post is a bit older, I'm also interested in a fixed script for waking up every day at the same time. My notebook (running unRAID on) isn't supporting it by default in the bios. Would be really nice, if someone could help me. Quote Link to comment
primeval_god Posted January 28, 2020 Share Posted January 28, 2020 @Kazino43 did you try the script posted above? It has been a while since i used s3 sleep with my server but the scripts on this page look correct. Quote Link to comment
Kazino43 Posted January 29, 2020 Share Posted January 29, 2020 (edited) It doesn't work at all. Getting it to sleep manually and with Dynamix Sleep automatically on schedule works great. But waking up doesn't work really. It wakes up, when I send a WOL signal from another PC or router, but not with this script. -Time is set correctly in the settings. -The script above: On 4/7/2018 at 11:43 AM, feraay said: time=09:55 now=$(date +%s) other=$(date -d $time +%s) if [ $now -ge $other ] then echo `date '+%s' --date='tomorrow 09:55:00'` > /sys/class/rtc/rtc0/wakealarm else echo `date '+%s' --date='today 09:55:00'` > /sys/class/rtc/rtc0/wakealarm fi is modified for testing to wake up 2-3min. after manual sleep, so I mean those time stamps (3 all in all ) are set with a different time stamps, 2 or 3 mins in the future. Just for the safety of using it wrong: It should be put in the "Custom commands before sleep:"? Tried both, but it didn't work either way. EDIT: AWW... Seems like it needs to shut down by itself (not manually) in order to run the script. I'm stupid, but tbh didn't thought this condition needs to be like that. I thought, that for the system, it is the same. But still one question: In which cistom comand box should it go: "Custom commands before sleep:" or "Custom commands after wake-up:" or both? Edited January 29, 2020 by Kazino43 Quote Link to comment
primeval_god Posted January 30, 2020 Share Posted January 30, 2020 19 hours ago, Kazino43 said: But still one question: In which cistom comand box should it go: "Custom commands before sleep:" or "Custom commands after wake-up:" or both? Custom commands before sleep Quote Link to comment
54tgedrg45 Posted June 7, 2020 Share Posted June 7, 2020 (edited) I wonder how Synology is able to wakeup when receiving things like SMB request, I can only think of basic packet detection done with some BMC interface. For my situation I assigned an old rpi to send magic packets to the Unraid on known clients ping status 0. as the operating times vary. a.t.m I have this current cron job for testing: #!/bin/bash # 20200607 # sudo crontab -e # sudo apt-get install etherwake # sudo apt-get install fping # Config MACADDR[0]="AA:BB:CC:DD:EE:FF" #MACADDR[1]="AA:BB:CC:DD:EE:FF" IPHOSTS[0]="x.x.x.x" #IPHOSTS[1]="x.x.x.x" IPCLIENS[0]="x.x.x.x" IPCLIENS[1]="x.x.x.x" NICID="ethx" # Wakeup wakeupDevice(){ printf "\nSending Magic WOL packet with: \n\tsudo etherwake $1 -i $2\n" sudo etherwake "$1" -i "$2" } triglog="/var/log/cron_triglog.log" lenh=${#MACADDR[@]} lenw=${#IPHOSTS[@]} if [ $lenh != $lenw ]; then echo "[$timestamp] Error: MACADDR and IPHOSTS array do not match in lenght, check config..." > $triglog exit 1 fi # Monitor every ~10 seconds for status i=0 while [ $i -lt 6 ]; do # NOTE: Use absulute paths! timestamp=$(date +%s) echo "$timestamp" hostsonline=false requestwol=false # Ping hosts for hip in ${IPHOSTS[*]}; do fping -c1 -t300 ${hip} 2>/dev/null 1>/dev/null if [ "$?" = 0 ]; then printf "Host %s found\n" ${hip} hostsonline=true else printf "Host %s not found\n" ${hip} hostsonline=false fi done # Ping clients if needed if [ ${hostsonline} = true ]; then printf "All hosts replied\n" else for cip in ${IPCLIENS[*]}; do fping -c1 -t300 ${cip} 2>/dev/null 1>/dev/null if [ "$?" = 0 ]; then printf "Client %s found\n" ${cip} requestwol=true else printf "Client %s not found\n" ${cip} fi done fi # Send WOL if [[ ${requestwol} = true && ${hostsonline} = false ]]; then echo "[$timestamp] WOL: Sending Magic WOL packet using ${MACADDR[$i]} - ${NICID}" >> $triglog for (( i=0; i<$lenw; i++ )); do wakeupDevice ${MACADDR[$i]} ${NICID} done fi sleep 9 # ~6 sec of tollerance, consider https://mmonit.com to manage jobs below 1 minute i=$(( i + 1 )) done Edited June 7, 2020 by 54tgedrg45 Quote Link to comment
I Enjoy Creating Videos Posted November 18, 2020 Share Posted November 18, 2020 Hello i need some help with this script i want to know what would i need to change to get my server to wake from sleep at 11:00PM every Saturday time=09:55 now=$(date +%s) other=$(date -d $time +%s) if [ $now -ge $other ] then echo `date '+%s' --date='tomorrow 09:55:00'` > /sys/class/rtc/rtc0/wakealarm else echo `date '+%s' --date='today 09:55:00'` > /sys/class/rtc/rtc0/wakealarm fi Quote Link to comment
corfoto4 Posted March 8, 2021 Share Posted March 8, 2021 (edited) On 6/12/2019 at 11:55 PM, OOmatrixOO said: It always works only on the first day. On the 2nd day the server stays in sleep mode. It seems that the alarm is not reset. Can somebody help me with it? Thank you. I know that this is an old post, but for everyone who still has the same problem of rtc working on the 1st day and not the second, this is my version of the code: echo 0 > /sys/class/rtc/rtc0/wakealarm time=5:58 now=$(date +%s) other=$(date -d $time +%s) if [ $now -ge $other ] then echo `date '+%s' --date='tomorrow 5:58:00'` > /sys/class/rtc/rtc0/wakealarm else echo `date '+%s' --date='today 5:58:00'` > /sys/class/rtc/rtc0/wakealarm fi This resets the rtc clock which will make the code work every day. echo 0 > /sys/class/rtc/rtc0/wakealarm I use this code because the rtc function in my bios doesn't wake UNRAID from sleep. But this code worked a treat! If you wish to change the time, change all of the time values to your desired time. This code also has to be placed in the 'custom commands before sleep' text box. Edited March 8, 2021 by corfoto4 1 Quote Link to comment
n3ro365 Posted April 12, 2021 Share Posted April 12, 2021 (edited) Yes, it works. Is it also possible to specify 2 times? So for example at 8 a.m. and 8 p.m.? Edited April 12, 2021 by OOmatrixOO Quote Link to comment
mgutt Posted September 1, 2021 Share Posted September 1, 2021 @OOmatrixOO I changed the script, so it supports multiple times, now: Quote Link to comment
cholzer Posted January 21, 2023 Share Posted January 21, 2023 (edited) On 4/7/2018 at 11:43 AM, feraay said: the script is only needed if you don't want the server to wake up every day. I do want the server to wake up every day, sadly the wake up timer in my bios does not seem to work as the system stays in sleep. gonna try this script now. thanks! Edited January 21, 2023 by cholzer 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.