Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

Is there a command to prevent the suspending of a system while another command executes?

For example; lets say I have an upload that I want to complete but it gets interrupted because of my machine suspending. Is there a command that I can use to execute another command that prevents my machine from sleeping until the command finishes?

share|improve this question
    
Consider including distro you're using in tags or the question as this might be slightly distro-dependent thing. –  Sami Laine Jan 3 at 12:34
    
@SamiLaine xargs and screen aren't distro dependent ;) –  josten Jan 3 at 13:41
    
@josten - SamiLaine is right, the solution might be dependent, better to include this info than not. –  slm Jan 3 at 15:01
add comment

2 Answers

GNOME2

If you're using a distro that uses a desktop derived from GNOME 2 you can use the application Caffeine to control when your system's screensaver and auto suspend kick in.

GNOME3

For GNOME 3 based distros you can use this GNOME shell extension, also called Caffeine.

Applet screenshot - shows enabled/disabled

                                                         ss of caffeine

NOTE: You can use it to control which applications will block the screen/suspend from occurring.

Applet's config dialog

    ss of config

setterm

untested by me

NOTE: I found this method in the comments of a Linux Journal article on Caffeine. Your mileage may vary with this solution, from what I understand, setterm is for controlling similar features such as blanking the screen and powersaving, but from a console perspective, not an X windows desktop.

$ setterm -powersave off -blank 0

For permanent change Add to your ~/.Xinitrc file or whatever dot file is approprite for running these commands as part of your environment:

setterm -blank 0 -powersave off -powerdown 0
xset s off

References

share|improve this answer
    
setterm is just for ttys, I'm pretty sure it won't have any effect in X. –  Chris Down Jan 3 at 15:02
    
@ChrisDown - that's what I thought too, was trying to investigate it further, on the off chance. I added a blurb about it only being for console. –  slm Jan 3 at 15:03
    
@ChrisDown - research seems to be backing up our understanding, I see no indications that it'll work for anything but console/tty. –  slm Jan 3 at 15:09
add comment
up vote 0 down vote accepted

I decided to write my own tool to do this using DBus; so far it seems to work just fine: https://bitbucket.org/josten/runt

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.