LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux Deepin (https://www.linuxquestions.org/questions/linux-deepin-101/)
-   -   Run script on resume (https://www.linuxquestions.org/questions/linux-deepin-101/run-script-on-resume-4175698588/)

KFoltz 08-01-2021 01:30 PM

Run script on resume
 
I am trying to run a script on resume after system suspend. Placed a script called test in /lib/systemd/system-sleep. Set the execution bit.

#!/usr/bin/env bash
#
# useless test script
#

echo "Reached test script at $(date)" >> tmp/result.txt
case "$1/$2" in
pre)
echo "we are suspending at $(date)..." >> tmp/result.txt
;;
post)
echo "we restarted at $(date)" >> tmp/result.txt
;;
esac

The script properly appends "Reached test script at $(date)" in tmp/result.txt when ran from terminal.

There is nothing placed in tmp/result.txt on suspend or resume.

journalctl -u systemd-suspend.service doesn't show any error messages.

Anyone have any idea what is wrong?

wpeckham 08-01-2021 04:01 PM

#1 you are using relative rather than absolute paths, without setting the current path in the script.

I have some other thoughts, but fix that and see if that is sufficient.

KFoltz 08-02-2021 11:29 AM

Quote:

Originally Posted by wpeckham (Post 6271501)
#1 you are using relative rather than absolute paths, without setting the current path in the script.

I have some other thoughts, but fix that and see if that is sufficient.

This is right. Using a fully specified path for the redirect fixes this problem.

Thanks
Kim Foltz


All times are GMT -5. The time now is 04:33 AM.