Skip to content
View in the app

A better way to browse. Learn more.

Unraid

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

How to automatically wake from sleep?

Featured Replies

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!

Wake at a specific time is typically enabled and configured in the BIOS, look for alarm or wake settings.

  • Author

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.

What about wake on LAN for a Windows 7 VM?

 

Sent from my XT1563 using Tapatalk

 

 

  • Author

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.

  • 9 months later...

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 by feraay

  • 8 months later...

Hello,

the script works great. Unfortunately, Unraid does not wake up on the weekend.

How should the script be changed to achieve this?

  • 4 months later...

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 by feraay

  • 1 year later...
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.

  • 7 months later...

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. 

@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. 

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 by Kazino43

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

  • 4 months later...

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 by 54tgedrg45

  • 5 months later...

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 

  • 3 months later...
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 by corfoto4

  • 1 month later...

Yes, it works.

Is it also possible to specify 2 times? So for example at 8 a.m. and 8 p.m.?

Edited by OOmatrixOO

  • 4 months later...
  • 1 year later...
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 by cholzer

  • 2 years later...

My NAS should always start up before I get home from work and should not go to sleep before I go to bed.

For this reason, I adapted the script from @feraay with the hint of @corfoto4 for my needs to wake up the NAS.
The function "excluded days" and "excluded hours" are used to prevent the NAS from going to sleep prematurely.

Perhaps some of you might be interested in my script:

Custom commands before sleep:

# 1. Define wake-up times for each day of the week (1=Mon … 7=Sun)

declare -A wake_times=(

[1]="16:00" # Monday

[2]="17:00" # Tuesday

[3]="16:00" # Wednesday

[4]="17:00" # Thursday

[5]="17:00" # Friday

[6]="07:00" # Saturday

[7]="07:00" # Sunday

)

# 2. Get today’s and tomorrow’s day numbers (1–7)

today=$(date +%u)

# Wrap-around: if today=7, tomorrow=1

tomorrow=$(( today % 7 + 1 ))

# 3. Look up wake-up times for today and tomorrow

wake_today=${wake_times[$today]}

wake_tomorrow=${wake_times[$tomorrow]}

# 4. Clear any existing RTC wakealarm

echo 0 > /sys/class/rtc/rtc0/wakealarm

# 5. Compute Unix timestamps for now, today’s wake-up and tomorrow’s wake-up

now_ts=$(date +%s)

today_ts=$(date -d "today $wake_today" +%s)

tomorrow_ts=$(date -d "tomorrow $wake_tomorrow" +%s)

# 6. Pick the next wake-up timestamp

if [ "$now_ts" -ge "$today_ts" ]; then

wake_ts=$tomorrow_ts

else

wake_ts=$today_ts

fi

# 7. Set the RTC wakealarm

echo "$wake_ts" > /sys/class/rtc/rtc0/wakealarm

Edited by petbrau

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...

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.