3

The ultimate goal is to have my system shut off at the end of a script and wake up at a defined time the next day. I'm using rtcwake to get this done, like so (I am also printing the date and time to the output just for comparison)

/bin/date
/usr/sbin/rtcwake -m off -l -t $(date -d "21:00 today" +"%s") -n

whose output is

Mon Sep 18 20:59:12 EDT 2017
rtcwake: wakeup from "off" using /dev/rtc0 at Mon Sep 18 17:00:00 2017

So, although the date and time returned by /bin/date are correct, and I (think that I) am setting the wakeup time for 21:00, rtcwake is interpreting the time as 17:00, 4 hours prior. (I realize that I am setting it to wake up the same day here. I want to get it working and then alter it to wake up the next day.)

To troubleshoot I altered the script a bit, removing the defined time, to read

/bin/date
/usr/sbin/rtcwake -m off -l -t $(date +"%s") -n

which gave the output

Mon Sep 18 21:14:46 EDT 2017
rtcwake: wakeup from "off" using /dev/rtc0 at Mon Sep 18 17:14:46 2017

which is again 4 hours prior to the actual time. This made me think that date doesn't have the correct time. But when I altered the script to remove the -l option from the rtcwake command

/bin/date
/usr/sbin/rtcwake -m off -t $(date +"%s") -n

the output was

Mon Sep 18 21:18:04 EDT 2017
rtcwake: assuming RTC uses UTC ...
rtcwake: wakeup from "off" using /dev/rtc0 at Tue Sep 19 01:18:04 2017 

which is now 4 hours after the current time. The 4 hour difference doesn't make sense to me, as I am on EDT (New York) and UTC is a 5 hour difference.

I played around some more and got the following:

1.

/bin/date
/usr/sbin/rtcwake -m off -t $(date +"%s" -d "tomorrow 10:00") -n

Mon Sep 18 21:19:11 EDT 2017
rtcwake: assuming RTC uses UTC ...
rtcwake: wakeup from "off" using /dev/rtc0 at Tue Sep 19 14:00:00 2017

2.

/bin/date
/usr/sbin/rtcwake -m off --date tomorrow 10:00 -n

Mon Sep 18 21:20:55 EDT 2017
rtcwake: assuming RTC uses UTC ...
rtcwake: wakeup from "off" using /dev/rtc0 at Tue Sep 19 04:00:00 2017

3

/bin/date
/usr/sbin/rtcwake -m off -l --date tomorrow 10:00 -n

Mon Sep 18 21:21:16 EDT 2017
rtcwake: wakeup from "off" using /dev/rtc0 at Mon Sep 18 20:00:00 2017

In conclusion: I think that rtcwake doesn't actually know what time it is, though I can't be sure that I'm even entering my wakeup date and time properly. I've opened the rtcwake and date manuals countless times, but I'm not seeing my issue. Many thanks in advance!

0

I have personally tested myself.

To test that I simply did "sudo rtcwake -m disk -s 60" , which simply hibernated it and waked it up after 1mins.

Thing here to note is that rctwake uses UTC and not your local time if not specified.

So now instead you need to sync your clock with your current time,then based on the difference change your "etc/adjtime" using sudo mode and change according to the difference.

In my case I use IST which is +5:30 i.e 5 hours 30 min ahead so I wrote "5:30" in the adjtime file.

Now If I use "sudo rtcwake --local -m disk -s 60" command it shows my IST time instead of the previous UTC time.

So from now you need to add "--local" or "-l" option too as mentioned in the manpage.

Example : "sudo rtcwake --local -m no -l -t $(date +%s -d ‘tomorrow 09:30’)"

would wake your system the next day at 9:30 am as per your local time from /dev/rtc0. After this you can set up a cron to set this up automatically.

Sources: rtcwake man page , from how to geek, some more configs

0

I was having a similar issue (rtcwake was using a different time than the "local" time), but after reading about the timedatectl command here I eventually realized my timezone was incorrect.

I set the timezone with this command:

timedatectl set-timezone MYTIMEZONE

After that rtcwake uses the correct time, even with the default settings (no need for me to specify --local.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.