I am writing a script that will automatically backup files on my computer to my network storage. This will run in the background as a cron job. Now assuming the script is running when I want to turn off my computer - is there any way I can have the suspend and shutdown process check if the backup script is running, and if so cancel, or at least provide me with the option to cancel the suspend/shutdown? I know that I can add scripts to /etc/pm/sleep.d and /etc/rc.shutdown.local that will run at the beginning of the process, but what actual command can I add that would stop the suspend/shutdown?
Тry to use this piece of code:
#!/bin/bash R=`pidof your_program_name` if [[ $R -ne "" ]] then while [[ $R -ne "" ]] do sleep 60 R=`pidof your_program_name` done else exit 0 fi
Accordingly, use custom hooks as described here. However I did not try this way.
Last edited by solamir (2012-09-04 21:05:27)