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?

  • Consider including distro you're using in tags or the question as this might be slightly distro-dependent thing.
    – user48669
    Jan 3 '14 at 12:34
  • @josten - SamiLaine is right, the solution might be dependent, better to include this info than not.
    – slm
    Jan 3 '14 at 15:01


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.


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


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


  • setterm is just for ttys, I'm pretty sure it won't have any effect in X.
    – Chris Down
    Jan 3 '14 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 '14 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 '14 at 15:09

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy