0

Somehow I cannot find how to do this common task.
I want to run a (backup) script daily at certain time regardless whether the system is running or suspended and return to the previous state afterwards.
I played with rtcwake and I have two major problems:

  1. I cannot tell if the system was woken up manually or by rtcwake
  2. It seems that if I resume the system manually, it forgets about rtcwake wake-up
10
  • That the system forgets about rtc wakup is an advantage I think, then you can include the return to suspend in the "after rtcwakeup" -script. How do you run the script right now? (cron / other script, do you use rsync etc) And what is your rtc command? Nov 7, 2014 at 17:02
  • At this moment I just run my script manually.<br>
    – Alex Bundy
    Nov 7, 2014 at 23:19
  • I respect your opinion, but nonetheless I have a different scenario that I'd like to use<br>
    – Alex Bundy
    Nov 7, 2014 at 23:20
  • I want to run the script automatically at certain time daily, preferably at the night when the machine is idle. It can be either suspended or alive and I want the script to run and return the system to its previous state.
    – Alex Bundy
    Nov 7, 2014 at 23:23
  • And what is 'after rtcwakeup' script? It seems that scripts in /etc/pm/sleep.d and /usr/lib/pm-utils/sleep.d are not being run on every wakeup.
    – Alex Bundy
    Nov 7, 2014 at 23:27

1 Answer 1

2

A single rtcwake does not work because with -m no option the command after && is being run immediately, not at wake time.
Anyway these two lines do the trick:

*/5 * * * * sudo rtcwake -m no -l -t $(date +\%s -d 'tomorrow 00:01')  
2 0 * * * /home/alex/perl/bkup/bkup.pl  

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .