[Solved] Computer does not turn on after setting alarm with rtcwake (Ubuntu 18.04)

Have a MythTV related problem? Ask for help from other MythTV users here.

Moderator: Forum Moderators

Post Reply
jhmgbl
Newcomer
Posts: 14
Joined: Mon Apr 14, 2014 4:19 pm
Germany

[Solved] Computer does not turn on after setting alarm with rtcwake (Ubuntu 18.04)

Post by jhmgbl »

I had a fine running Mythbuntu 14.04 System which automatically turned the computer off and on using setwakeup.sh from the wiki but now with 18.04 I had to modify the script using rtcwake and the computer does not turn on any more although the alarm thime is set correctly.

Here is my script

Code: Select all

#!/bin/sh
#
# set ACPI Wakeup time
# usage: setwakeup.sh seconds
#    seconds - number of seconds from epoch to UTC time (time_t time format)
#
# set UTCBIOS to true if bios is using UTC time
# set UTCBIOS to false if bios is using local time

UTCBIOS=true

if $UTCBIOS
then
    #utc bios - use supplied seconds
    SECS=$1
else
    #non utc bios - convert supplied seconds to seconds from
    #epoch to local time
    SECS=`date -u --date "\`date --date @$1 +%F" "%T\`" +%s`
fi

echo 0 > /sys/class/rtc/rtc0/wakealarm    # clear alarm
echo $SECS > /sys/class/rtc/rtc0/wakealarm   # write the waketime
/usr/sbin/rtcwake --mode no -u --time $SECS
Last edited by jhmgbl on Wed Mar 27, 2019 9:34 pm, edited 1 time in total.
User avatar
bill6502
Developer
Posts: 2325
Joined: Fri Feb 07, 2014 5:28 pm
United States of America

Re: Computer does not turn on after setting alarm with rtcwake (Ubuntu 18.04)

Post by bill6502 »

Hi,

Works for me. If you haven't, just test from the command line (it shouldn't be
a MythTV issue.)

Code: Select all

sudo rtcwake --mode no --time $((`date +'%s'` + 120)) --utc
sudo /bin/systemctl poweroff
My host powered up in 120 seconds, as expected. And this test was on 18.04.
jhmgbl
Newcomer
Posts: 14
Joined: Mon Apr 14, 2014 4:19 pm
Germany

Re: Computer does not turn on after setting alarm with rtcwake (Ubuntu 18.04)

Post by jhmgbl »

My pc does not turn on again it is the same hardware as with my 14.04 installation and there it worked! Is it really not necessary tho modify the shutdown script, so that the hardware clock is not overwritten on shutdown?
User avatar
bill6502
Developer
Posts: 2325
Joined: Fri Feb 07, 2014 5:28 pm
United States of America

Re: Computer does not turn on after setting alarm with rtcwake (Ubuntu 18.04)

Post by bill6502 »

I understand the issue. I wouldn't change the shutdown script until the
2 commands above work. I've removed the echos to /sys/class/rtc/rtc0/wakealarm
from my script though.

Could it be that your system doesn't require the --utc switch?

timedatectl will tell you (on the 3rd and last lines) if RTC is local.

If you add your motherboard maker/version here, maybe someone else reading
this thread will comment on their ability to wakeup.

Forgot to mention hwclock is masked in 18.04. systemctl status hwclock.service
Last edited by bill6502 on Sun Mar 24, 2019 2:50 pm, edited 1 time in total.
Reason: Added hwclock masked
jhmgbl
Newcomer
Posts: 14
Joined: Mon Apr 14, 2014 4:19 pm
Germany

Re: Computer does not turn on after setting alarm with rtcwake (Ubuntu 18.04)

Post by jhmgbl »

from lshw:

*-core
Beschreibung: Hauptplatine
Produkt: M5A78L-M/USB3
Hersteller: ASUSTeK Computer INC.
Physische ID: 0
Version: Rev X.0x
Seriennummer: 160162721401263
Steckplatz: To Be Filled By O.E.M.
jhmgbl
Newcomer
Posts: 14
Joined: Mon Apr 14, 2014 4:19 pm
Germany

Re: Computer does not turn on after setting alarm with rtcwake (Ubuntu 18.04)

Post by jhmgbl »

The motherboard is ASUS M5A78L-M/USB3
MikeB2013
Senior
Posts: 519
Joined: Mon Jul 25, 2016 4:16 pm
Great Britain

Re: Computer does not turn on after setting alarm with rtcwake (Ubuntu 18.04)

Post by MikeB2013 »

I have the same motherboard, M5A78L-M/USB3, BIOS 2101 12/02/2014 with Xubuntu 18.04
There is an issue with hpet in the bios in that it stops the machine from powering up.
In file /etc/default/grub I have the following

Code: Select all

GRUB_CMDLINE_LINUX_DEFAULT="hpet=disable tsc=unstable"
Try this GRUB_CMDLINE change before anything else, like changing /usr/bin/setwakeup.sh, mine is below
Remember to run after changing this file followed by a reboot.

Code: Select all

sudo update-grub
The contents of my file /usr/bin/setwakeup.sh (slightly modified from wiki) are:

Code: Select all

#!/bin/bash
#$1 is the first argument to the script. It is the time in seconds since 1970
#this is defined in mythtv-setup with the time_t argument

#echo 0 > /sys/class/rtc/rtc0/wakealarm      #this clears your alarm.
#echo $1 > /sys/class/rtc/rtc0/wakealarm     #this writes your alarm
sudo rtcwake -m no -t $1
LOG_FILE='/var/log/mythtv/hwclock-rebootTime.log' #log file

# Now write the time the system is expected to come out of power save mode
# so there is at least a small record of when if it was supposed to recover

# Note:- Log file will just keep growing

# date in Epoch format
a="`date  +%s`"

# Subtract Current time from Future time
let "b=$1-$a"

# echo $b
# echo "result of time subtraction `date -d @$b`"

# Get Date and Subtract 1,.. as date starts from 1st Jan 1970
dte=`date -d @$b +%d`
let "dte -= 1"

echo "Current Time      ->`date`" >> $LOG_FILE

# Simple check to determine if to include days in output string
if (dte=0)
then
    echo "Shutting down for ->`date -d @$b +%Hhrs:%MMins`" >> $LOG_FILE
else
    echo "Shutting down for ->$[dte]Days `date -d @$b +%Hhrs:%MMins`" >> $LOG_FILE
fi

echo "Wake up at approx.->`date -d @$1`"  >> $LOG_FILE
echo "------------------------------------------------------" >> $LOG_FILE

jhmgbl
Newcomer
Posts: 14
Joined: Mon Apr 14, 2014 4:19 pm
Germany

Re: Computer does not turn on after setting alarm with rtcwake (Ubuntu 18.04)

Post by jhmgbl »

Thanks a lot! It works now!
User avatar
Steve Goodey
Moderator
Posts: 220
Joined: Fri Feb 07, 2014 6:30 pm
Location: Colchester, England
Great Britain

Re: Computer does not turn on after setting alarm with rtcwake (Ubuntu 18.04)

Post by Steve Goodey »

Hi, if you're happy could you amend your first post and add [Solved] to the end of the subject line, thanks.
Don't forget the Wiki.
knappster
Junior
Posts: 34
Joined: Wed Aug 01, 2018 1:42 am
United States of America

Re: [Solved] Computer does not turn on after setting alarm with rtcwake (Ubuntu 18.04)

Post by knappster »

jhmgbl, what fixed it for you? I had a similar issue when I upgraded a kernel version in Arch Linux with motherboard:
M5A78L-M LX3

I made a script to use wake-on-lan from a raspberry pi to wake my machine instead. For me:
$ cat /sys/devices/system/clocksource/clocksource0/current_clocksource
tsc
So I am not sure if the grub update would fix it for me since it is not using hpet anyway.
knappster
Junior
Posts: 34
Joined: Wed Aug 01, 2018 1:42 am
United States of America

Re: [Solved] Computer does not turn on after setting alarm with rtcwake (Ubuntu 18.04)

Post by knappster »

I am using a distro named Linhes which is based on arch. I've experimented and found for me the best kernel option so far is

Code: Select all

hpet=disable
without the bit about tsc. I actually had to update a header file in /etc/grub.d in my distro as the GRUB_CMDLINE_LINUX_DEFAULT was not applied to the menu item I needed.

Thanks for the help. This has been bugging me for about a year!
Post Reply