keep computer from sleeping when terminal is active

Asked by Roy Lowrance

On Ubuntu 10.10, I have set my power management preferences to put computer to sleep when inactive for 2 hours.

I run a long-running job in the terminal (it will run for days). After the 2 hours, Ubuntu sleeps my computer.

Is there a way to tell Ubuntu that the job running in the terminal constitutes activity and hence the computer should not sleep while it is running?

Question information

Language:
English Edit question
Status:
Solved
For:
Ubuntu gnome-power-manager Edit question
Assignee:
No assignee Edit question
Solved by:
mycae
Solved:
Last query:
Last reply:
Revision history for this message
Best mycae (mycae) said :
#1

run this command before you start your job:

OLD_POWER_SETTING=`gconftool-2 --get /apps/gnome-power-manager/timeout/sleep_computer_ac`

gconftool-2 --set /apps/gnome-power-manager/timeout/sleep_computer_ac 0

 --- Do job ---

gconftool-2 --set /apps/gnome-power-manager/timeout/sleep_computer_ac $OLD_POWER_SETTING

Revision history for this message
Roy Lowrance (roy-lowrance) said :
#2

thx.

Would be nice to be able to do this through the UI though.

Revision history for this message
mycae (mycae) said :
#3

You can -- I assumed you wanted a way to batch automate it from the terminal.

Go to the power settings, and disable the sleep function.

System->Preference->Power management->Put comptuer to sleep (never)

Revision history for this message
Roy Lowrance (roy-lowrance) said :
#4

That's what I do now.

I would think that jobs started explicitly from a terminal would count as activity and hence even the Power Management panel would not count the compute as inactive when these jobs were running.

Revision history for this message
mycae (mycae) said :
#5

You could modify gnome-terminal to actually be a shell script with those settings.

==FILE CONTENTS BELOW====
#!/bin/bash
OLD_POWER_SETTING=`gconftool-2 --get /apps/gnome-power-manager/timeout/sleep_computer_ac`
gconftool-2 --set /apps/gnome-power-manager/timeout/sleep_computer_ac 0

real-gnome-terminal

gconftool-2 --set /apps/gnome-power-manager/timeout/sleep_computer_ac $OLD_POWER_SETTING
==FILE CONTENTS ABOVE====

Just be aware that updates could knock this out. Or you could call it "my-gnome-terminal" instead.