How to have openSUSE 13.1 KDE resume from suspend at set time?

System is openSUSE 13.1 KDE 32-bit with all updates. I installed Back in Time 1.0.34, and configured it to do incremental backups daily at 2:00 AM. It works correctly if the system is running at 2:00 AM, but nothing happens if the system is suspended to RAM.

How can I get the system to resume daily at say 1:55 AM so the backup runs?

I looked at rtcwake, but it seems like a one-shot approach, not something that will run daily.

I’m trying to duplicate the function of Windows task scheduler, which has a selectable option to wake the system to run a task.

How can this be done in openSUSE?

Thanks,
Howard

I’ve never had need to do this, but have a look at

man rtcwake

That might provide what you need.

On 2014-06-18 02:16, crmrhm wrote:

> I looked at rtcwake, but it seems like a one-shot approach, not
> something that will run daily.

Did you try?

If you confirm it does that, you can simply set it up again when your
backup job ends.

But it appears that you have to call it every time you suspend, instead
of the default call.


Cheers / Saludos,

Carlos E. R.
(from 13.1 x86_64 “Bottle” at Telcontar)

On Wed, 18 Jun 2014 00:16:01 +0000, crmrhm wrote:

> I looked at rtcwake, but it seems like a one-shot approach, not
> something that will run daily.

Not on its own, maybe, but a cron job to schedule it would solve that.

Jim


Jim Henderson
openSUSE Forums Administrator
Forum Use Terms & Conditions at http://tinyurl.com/openSUSE-T-C

AFAICT, rtcwake has two ways to set a wake time:

  1. Sets the wakeup time to seconds in future from now.

  2. Sets the wakeup time to the absolute time time_t. time_t is the time in seconds since 1970-01-01, 00:00 UTC.

This backup is desired on systems that randomly suspend and resume during the day.

Option 1 could be run daily by a cron job to wake after some elapsed time, but the system has to be up for the cron job to run, and that is uncertain.

Option 2 requires a new absolute time set daily.

I find no way for rtcwake to use a relative time, such as 1:55 AM daily.

Back in Time can use anacron to schedule execution. This will run it after anything has caused the system to resume. I’ll try this approach. It would be nice to have the backup run every night when all is quiet, but I can see no way to make that happen automatically.
Regards,
Howard

On Wed, 18 Jun 2014 05:06:01 +0000, crmrhm wrote:

> 2) Sets the wakeup time to the absolute time time_t. time_t is the time
> in seconds since 1970-01-01, 00:00 UTC.
>
> This backup is desired on systems that randomly suspend and resume
> during the day.
>
> Option 1 could be run daily by a cron job to wake after some elapsed
> time,
> but the system has to be up for the cron job to run, and that is
> uncertain.
>
> Option 2 requires a new absolute time set daily.

Option 2 would be the simplest, since it wouldn’t take much scripting to
generate a date string that was for “tomorrow” and plug that in as a
parameter to rtcwake. The date command can give you the time_t value
based on a string value IIRC; the conversion is a pretty standard
conversion.

In fact, if you figure out the time on one particular date, the number of
seconds to the next time is a fixed value (86400 IIRC), so it actually is
just simple addition to the previous wake value if you know what that is
(and you could store that somewhere, then read it, compute the new value,
write it back to the temp file, and use it for the next scheduled rtcwake
call).

Jim


Jim Henderson
openSUSE Forums Administrator
Forum Use Terms & Conditions at http://tinyurl.com/openSUSE-T-C

On 2014-06-18 07:06, crmrhm wrote:
>
> AFAICT, rtcwake has two ways to set a wake time:
>
> 1) Sets the wakeup time to seconds in future from now.
>
> 2) Sets the wakeup time to the absolute time time_t. time_t is the time
> in seconds since 1970-01-01, 00:00 UTC.

AFAICS, there is another problem.

rtcwake sets the computer to sleep now, with a wake up time programmed.

At least, that is how I understand the man page:

rtcwake - enter a system sleep state until specified wakeup time

rtcwake [options] -d device] -m standby_mode] {-t time_t|-s seconds}

Thus, you specify a sleep mode (standby, hibernate, etc), and when to
wake up. And it goes into that state immediately. That being so, you
have to replace the system call to sleep with a call to rtcwake instead.


Cheers / Saludos,

Carlos E. R.
(from 13.1 x86_64 “Bottle” at Telcontar)

One of rtcwake’s standby_modes is

no          Don't suspend. The rtcwake command sets RTC wakeup time only.

so the system does not go to sleep, just changes the wake time.

Looks like it is finally time for me to learn something about scripting. And 86400 is correct.
Thanks,
Howard

On 2014-06-18 17:06, crmrhm wrote:
>
> robin_listas;2649547 Wrote:

>> Thus, you specify a sleep mode (standby, hibernate, etc), and when to
>> wake up. And it goes into that state immediately. That being so, you
>> have to replace the system call to sleep with a call to rtcwake instead.

> One of rtcwake’s standby_modes is
> Code:
> --------------------
> no Don’t suspend. The rtcwake command sets RTC wakeup time only.
> --------------------
> so the system does not go to sleep, just changes the wake time.

Ah, I did not see that one.

Then you can issue that command after running the backup job, and on
other occasions. Let me think… Ah, place a script in /etc/pm/sleep.d/,
to trigger on suspend/hibernate.

/etc/pm/sleep.d/06wakeup:


#!/bin/bash

.. /usr/lib/pm-utils/functions

case "$1" in
hibernate|suspend)
rtcwake ... something.
;;
*)
;;
esac
exit $?

That would automatically activate it every time you suspend. :slight_smile:


Cheers / Saludos,

Carlos E. R.
(from 13.1 x86_64 “Bottle” at Telcontar)

crmrhm wrote:

>
> robin_listas;2649547 Wrote:
>> AFAICS, there is another problem.
>>
>> rtcwake sets the computer to sleep now, with a wake up time
>> programmed.
>>
>> At least, that is how I understand the man page:
>>
>> rtcwake - enter a system sleep state until specified wakeup time
>>
>> rtcwake [options] -d device] -m standby_mode] {-t time_t|-s
>> seconds}
>>
>>
>> Thus, you specify a sleep mode (standby, hibernate, etc), and when to
>> wake up. And it goes into that state immediately. That being so, you
>> have to replace the system call to sleep with a call to rtcwake
>> instead.One of rtcwake’s standby_modes is
> Code:
> --------------------
> no Don’t suspend. The rtcwake command sets RTC wakeup
> time only.
> --------------------
> so the system does not go to sleep, just changes the wake time.
>
>
Have you actually tried it? On my system rtcwake does put the system
to sleep. (opensuse 13.1 KDE 4.11)


*********** To reply by e-mail, make w single in address **************

Same here. I tested with the default mode (standby) and with the mem mode. Both times the system went sleeping and started again after the prescribed number of seconds.

I just ran

HPa730n-oS131:/home/howard #  rtcwake -m no -s 44
rtcwake: wakeup using /dev/rtc0 at Wed Jun 18 11:15:05 2014
HPa730n-oS131:/home/howard #

With -m mode set as “no”, the system did not go to sleep. I manually put it to sleep with the keyboard sleep key, and it woke up automatically after 44 seconds.
Regards,
Howard