LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Linux Deepin
User Name
Password
Linux Deepin This forum is for the discussion of Linux Deepin.

Notices


Reply
  Search this Thread
Old 08-01-2021, 02:30 PM   #1
KFoltz
LQ Newbie
 
Registered: Apr 2020
Posts: 20

Rep: Reputation: Disabled
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?
 
Old 08-01-2021, 05:01 PM   #2
wpeckham
LQ Guru
 
Registered: Apr 2010
Location: Continental USA
Distribution: Debian, Ubuntu, RedHat, DSL, Puppy, CentOS, Knoppix, Mint-DE, Sparky, VSIDO, tinycore, Q4OS,Manjaro
Posts: 5,437

Rep: Reputation: 2638Reputation: 2638Reputation: 2638Reputation: 2638Reputation: 2638Reputation: 2638Reputation: 2638Reputation: 2638Reputation: 2638Reputation: 2638Reputation: 2638
#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.
 
1 members found this post helpful.
Old 08-02-2021, 12:29 PM   #3
KFoltz
LQ Newbie
 
Registered: Apr 2020
Posts: 20

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by wpeckham View Post
#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
 
  


Reply

Tags
resume, systemd


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
desktop suspends? but reboots on resume as a result of runlevel 0 on resume? dimm0k Slackware 5 04-06-2020 02:46 PM
resume: could not stat the resume device file Zaskar Debian 17 03-29-2012 11:10 PM
[SOLVED] Why do nVida drivers hose suspend/resume or hibernate/resume? taylorkh Linux - Hardware 3 06-23-2011 02:09 PM
resume: cannot stat resume device file sixerjman Linux - Kernel 0 05-27-2007 04:09 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Linux Deepin

All times are GMT -5. The time now is 09:41 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration