Score:0

Running command before suspend

ng flag

I've found several posts (e.g., How do I run commands on suspend/return from suspend?, How to run a script before suspend?, Script not running on resume/wakeup in Ubuntu) that describe adding a script in /etc/pm/sleep.d or /usr/lib/pm-utils/sleep.d to execute commands at suspend/resume. However, I haven't been able to get this to work; the script seems to never execute despite having rx permissions for root. I went all the way back to simply having the script execute an echo that outputs to a file just to confirm and that nothing happens. (See script at bottom.)

What I want to accomplish is to have the suspend execute a script that runs rtcwake to implement a wake-up in the early morning for a maintenance script to run. I cannot just execute the maintenance script from cron since the system is suspended. So, I need to resume the system at a specific time in advance and then allow the job to execute.

#!/bin/bash/
case "${1}" in
  suspend)
    #suspend_actions
    echo "suspend" >> text.out
    ;;
  resume)
    #resume_actions
    echo "resume" >> text.out
    ;;
esac
waltinator avatar
it flag
Use the full path to `text.out`, e.g. `/tmp/text.out`.
waltinator avatar
it flag
Why not RTCWake the system at 06:00, and schedule the cron job for 06:30?
ng flag
@waltinator -- That is exactly what I'm attempting to do. But the problem I have is that rtcwake is a one time deal (best I can determine). I can set it for one wakeup (e.g., at 3am) but I can't run it and have it wake up *everyday* at 3am. And I did try some explicit paths but they didn't change anything. Scripts in sleep.d run as root so it should be able to write anywhere, yes?
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.