Scheduled wake from sleep?


Recommended Posts

Hi, like many, I would like my unRAID box to sleep when it is idle and either wake-on-lan or wake on schedule.  I've installed the Dynamix S3 sleep plugin and it sort of works (that is, it works while I'm at my desk sending the unRAID box to sleep then reviving it by sending the WoL packet, but if I leave the unRAID box sleeping for a day and try again the results are very iffy).  I have found absolutely no way of getting this box to wake on schedule other than by having another (Windows) PC wake up to send the WoL packet to the unRAID box!  I'm sure there has to be something more elegant than this, can anyone tell me what I'm missing?  For reference, I'm running a pretty vanilla set-up with the latest version of unRAID, on a motherboard that supports S3.

Link to comment

A scheduled wake up is configured in the BIOS.

Check your mainboard's manual if this functionality is available.

 

Look for something like "RTC" settings or "wake on RTC" or "resume by RTC"

 

Most of the time the possible settings are quite basic and you will probably loose the WoL functionality.

Perhaps you can run a WoL script on something like your router or mobile phone?

Edited by Fireball3
Link to comment
17 minutes ago, ralphbecket said:

I wonder what Windows does to make this work that doesn't require BIOS changes.

I don't understand why you think it does?

If I understand correctly, you used a Windows machine to send the WoL packet to your server!?

I feel that there is some misunderstanding somewhere.

 

Probably related to this?

1 hour ago, ralphbecket said:

but if I leave the unRAID box sleeping for a day and try again the results are very iffy

You mean it won't wake when you send the WoL packet?

Edited by Fireball3
Link to comment

Hi, @Fireball3.  The Windows Task Scheduler includes an option to wake the computer from sleep if necessary, which has always worked reliably for me without requiring any extra BIOS tweaks.  I'm just wondering how Windows manages this, but not Linux.

 

Re: the iffy WoL results after the unRAID box has been sleeping for a day or so, yes: sometimes it will wake when I send the packed from another PC, sometimes it won't.  I haven't been able to discern any pattern, unfortunately.

 

Link to comment
2 hours ago, Fireball3 said:

If your router is rebooted, he will loose the reference where the server was plugged to. The packet won't reach its destination and the wake will not take place.
Maybe this happened?

Same thing can happen if you are using a dynamic IP address and it expires while the server is asleep.

Edited by primeval_god
Link to comment

Hmm, I'll try it: we've just installed a new router, it's possible the previous one was having trouble.

 

On the other hand, I notice that unRAID comes with 'rtcwake' installed, but when I try it I get a write error:

root@Tower:~# rtcwake -s 30 -v
rtcwake: assuming RTC uses UTC ...
Using UTC time.
        delta   = -4
        tzone   = 0
        tzname  = UTC
        systime = 1497921001, (UTC) Tue Jun 20 01:10:01 2017
        rtctime = 1497921005, (UTC) Tue Jun 20 01:10:05 2017
alarm 0, sys_time 1497921001, rtc_time 1497921005, seconds 30
rtcwake: wakeup from "suspend" using /dev/rtc0 at Tue Jun 20 01:10:36 2017
suspend mode: suspend; suspending system
rtcwake: write error

 

Link to comment

@primeval_god Ha ha, that worked!  Thanks a million.  I just tried out the following experiment and it worked perfectly: https://ragsagar.wordpress.com/2011/08/15/how-to-automatically-wake-up-your-computer-at-a-particular-time-resume-by-rtc-alarm-in-arch-linux/

 

I spoke too soon, I think I see what has been corrupting my flash drives now.  Resuming from sleep as above, I observe that my docker tab is gone and the log file contains the following:


Jun 20 11:49:32 Tower kernel: xhci_hcd 0000:03:00.0: HC died; cleaning up
Jun 20 11:49:32 Tower kernel: dpm_run_callback(): usb_dev_resume+0x0/0x10 returns -22
Jun 20 11:49:32 Tower kernel: PM: Device 6-2 failed to resume async: error -22
Jun 20 11:49:32 Tower kernel: PM: resume of devices complete after 11021.862 msecs
Jun 20 11:49:32 Tower kernel: Restarting tasks ... 
Jun 20 11:49:32 Tower kernel: usb 6-2: USB disconnect, device number 2
Jun 20 11:49:32 Tower kernel: done.
Jun 20 11:49:32 Tower kernel: udevd[18947]: inotify_add_watch(5, /dev/sda, 10) failed: No such file or directory
Jun 20 11:49:32 Tower s3_sleep: Wake-up from sleep mode
Jun 20 11:49:32 Tower kernel: FAT-fs (sda1): Directory bread(block 8192) failed
Jun 20 11:49:32 Tower kernel: FAT-fs (sda1): Directory bread(block 8193) failed
Jun 20 11:49:32 Tower kernel: FAT-fs (sda1): Directory bread(block 8194) failed
Jun 20 11:49:32 Tower kernel: FAT-fs (sda1): Directory bread(block 8195) failed
Jun 20 11:49:32 Tower kernel: FAT-fs (sda1): Directory bread(block 8196) failed
Jun 20 11:49:32 Tower kernel: FAT-fs (sda1): Directory bread(block 8197) failed
Jun 20 11:49:32 Tower kernel: FAT-fs (sda1): Directory bread(block 8198) failed
Jun 20 11:49:32 Tower kernel: FAT-fs (sda1): Directory bread(block 8199) failed
Jun 20 11:49:32 Tower kernel: FAT-fs (sda1): Directory bread(block 8200) failed
Jun 20 11:49:32 Tower kernel: FAT-fs (sda1): Directory bread(block 8201) failed
Jun 20 11:49:32 Tower root: 
Jun 20 11:49:32 Tower root: Warning: file_put_contents(/boot/config/docker.cfg): failed to open stream: No such file or directory in /usr/local/emhttp/plugins/dynamix.docker.manager/scripts/dockerconfig.php on line 35
Jun 20 11:49:32 Tower root: 
Jun 20 11:49:32 Tower root: Warning: file_put_contents(/boot/config/domain.cfg): failed to open stream: No such file or directory in /usr/local/emhttp/plugins/dynamix.vm.manager/scripts/libvirtconfig.php on line 39
Jun 20 11:51:50 Tower kernel: fat__get_entry: 182 callbacks suppressed
Jun 20 11:51:50 Tower kernel: FAT-fs (sda1): Directory bread(block 8192) failed
Jun 20 11:51:50 Tower kernel: FAT-fs (sda1): Directory bread(block 8193) failed
Jun 20 11:51:50 Tower kernel: FAT-fs (sda1): Directory bread(block 8194) failed
Jun 20 11:51:50 Tower kernel: FAT-fs (sda1): Directory bread(block 8195) failed
Jun 20 11:51:50 Tower kernel: FAT-fs (sda1): Directory bread(block 8196) failed
Jun 20 11:51:50 Tower kernel: FAT-fs (sda1): Directory bread(block 8197) failed
Jun 20 11:51:50 Tower kernel: FAT-fs (sda1): Directory bread(block 8198) failed
Jun 20 11:51:50 Tower kernel: FAT-fs (sda1): Directory bread(block 8199) failed
Jun 20 11:51:50 Tower kernel: FAT-fs (sda1): Directory bread(block 8200) failed
Jun 20 11:51:50 Tower root: 
Jun 20 11:51:50 Tower root: Warning: file_put_contents(/boot/config/docker.cfg): failed to open stream: No such file or directory in /usr/local/emhttp/plugins/dynamix.docker.manager/scripts/dockerconfig.php on line 35
Jun 20 11:51:50 Tower kernel: FAT-fs (sda1): Directory bread(block 8201) failed
Jun 20 11:51:50 Tower root: 
Jun 20 11:51:50 Tower root: Warning: file_put_contents(/boot/config/domain.cfg): failed to open stream: No such file or directory in /usr/local/emhttp/plugins/dynamix.vm.manager/scripts/libvirtconfig.php on line 39

 

Edited by ralphbecket
Link to comment

Sorry for the delay, I can confirm that I am not doing anything special in the before sleep command other than setting the rtc. I dont know if it matters but when i set the RTC i first "echo 0 > /sys/class/rtc/rtc0/wakealarm" to clear it. As I said I have never had any flash drive issues. Shot in the dark, maybe you could try plugging the flash drive into a different USB controller on your mobo.

Link to comment

No problem, I'm just grateful to receive advice (for which many thanks!).  I'll try both your suggestions over the weekend and let you know how it works out.  What's interesting is that this is a replacement flash drive: I was seeing the same kinds of problems with my previous flash, but this suggests the problem lies elsewhere.

Link to comment
  • 1 year later...

Hey Please check my script here:

 

https://forums.unraid.net/topic/47160-how-to-automatically-wake-from-sleep/?tab=comments#comment-649452

 

Example Monday to Friday wakeup at 9.55

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

 

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.