2

I have a script launched by a cron from an Kubuntu 12.04.01 LTS laptop to NAS. The script simply contains an rsync command backing up the laptop.

The problem is that if the system goes into standby mode, while the script is executing, the network manager crashes and the whole thing fails. Even without the crash, I would still like the computer to remain awake until the backup is finished.

Ideally, I would like to add a command at the top of the script to disable standby/hibernation and another at the end of the script to re-enable it before exiting the script.

I have seen these two related threads already, but neither quite gives me what I need (I think):

Automatically sleep and wake-up at specific times

How to inhibit suspend temporarily?

1 Answer 1

1

The second thread you linked gives two perfect solutions:

  1. Have a loop run xdotool to cause input to prevent the system from being seen as idle

  2. Or:

    A script in /usr/lib/pm-utils/sleep.d can check if the application is running and return 1 to indicate that suspend should be prevented.

4
  • Thanks blujay. Actually I did manage to adapt the second solution sometime later but forgot to update the question. I've got the script saving file into sleep.d which returns '1' as suggested and the file is deleted upon completion of the script or next login (whichever is soonest (incase an unexpected shutdown occurs before the backup finished). Thanks. May 6, 2013 at 6:05
  • Where is the quoted part from, and what should the script contain?
    – naught101
    Sep 29, 2013 at 11:43
  • @naught101 I suppose you could have the script simply do: if pgrep -f foobar; then exit 1; fi It sounds like Peter did it differently though: his backup script creates a script in /usr/lib/pm-utils/sleep.d that simply does exit 1, and then when his backup script finishes, it deletes the script. If you do it this way, make sure to trap on EXIT INT TERM so it will delete the script if it's aborted.
    – user41313
    Apr 28, 2014 at 4:40
  • How would one "Have a loop run xdotool to cause input to prevent the system from being seen as idle"? What sort of input is needed? How would one get xdotool to export the output to the correct display from the commandline? Jun 25, 2014 at 0:09

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .