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
text.out
, e.g./tmp/text.out
. – waltinator Jan 27 '22 at 21:25