I want to run a 4 commands before a hibernate and another 2 commands after update. Is it also possible to arrange the time/squence of each commands,if yes then could you explain how?
Asked
Active
Viewed 6,227 times
1 Answers
8
You can run commands before and after hibernation or suspension (note there is a difference; hibernation is to disk, suspension is to memory) by creating a script in /etc/pm/sleep.d
:
#!/bin/bash
case "$1" in
hibernate)
# put commands to run on hibernation here
;;
thaw)
# put commands to run when returning from hibernation here
;;
suspend)
# put commands to run on suspend here
;;
resume)
# put commands to run when returning from suspension
;;
esac
The filename of the script will dictate the order in which the scripts run compared to other scripts in sleep.d. Within your script, your commands will run in whatever order you put then in the script.

David Edwards
- 5,168
root
. So if you need to stop/start some non-system application (for example, Dropbox) run corresponding command as usual user with aid ofsu
(for example,su --command 'dropbox start' user
. – flaz14 Jul 16 '16 at 14:37