0

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
AdvApp
  • 217
  • 3
  • 12
  • Use the full path to text.out, e.g. /tmp/text.out. – waltinator Jan 27 '22 at 21:25
  • Why not RTCWake the system at 06:00, and schedule the cron job for 06:30? – waltinator Jan 27 '22 at 23:37
  • @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? – AdvApp Jan 29 '22 at 08:04

0 Answers0