Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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 '14 at 12:34
@SamiLaine xargs and screen aren't distro dependent ;) – jersten Jan 3 '14 at 13:41
@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


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 '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
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

Your Answer


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.