Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I want to do a large disk transfer, which slows down responsiveness of my system.

What I want is a Unix command that will only run the command after I have been idle at the console for a few minutes. And if I come back half way in, it will suspend the job. Until I walk away from my computer.

Is there such a command, or software package?

[edit: The key part of this question is how to determine if there is console activity, to automatically suspend.]

share|improve this question
    
At a text console or X? –  James Mar 31 '10 at 22:34

5 Answers 5

You can achieve this by first getting the process PID with:

ps aux | grep <process_name>

write down the PID (it's the second column), then suspend it with:

kill -STOP <pid>

and continue it with:

kill -CONT <pid>
share|improve this answer
    
This doesn't tell me how to detect if there is console activity, which is the more tricky part AFAIK. –  Joseph Turian Mar 31 '10 at 19:19

How about just running the command normally, and then using "nice" on it to lower its priority?

share|improve this answer
    
linux.die.net/man/1/nice –  Zoredache Mar 16 '10 at 17:51
2  
You'll probably want to use 'ionice' if it's disk bound, rather than 'nice' –  James Mar 16 '10 at 18:55
1  
'nice' has almost no affect. 'ionice' mostly works, but even at the "nicest" value, heavy I/O will noticeably slow down other processes. The only reliable solution I have found for this is pausing the processes occasionally to let the I/O load settle. –  Mark Porter Mar 16 '10 at 19:03

I once wrote a "pause_io" script that would accept a number and then pgrep all the types of things that are likely to whomp my IO, e.g. rsync, updatedb, and cp. Then it would kill -STOP those pids and sleep for the supplied number of minutes and then kill -CONT each of them. When I needed responsive access to the box I would execute

    pause_io 10 &

And I would have 10 minutes without heavy I/O

It went something like this:

    #!/bin/bash

    TIMEOUT=$(($1*60))
    TASKS="mlocate|updatedb|rsync|cp"

    pkill $TASKS -signal STOP
    sleep $TIMEOUT
    pkill $TASKS -signal CONT
share|improve this answer

rsync has a --bwlimit option.

share|improve this answer
    
be aware the the "bwlimit" only affects file transfer, not the file analysis. If you are analyzing something big, like for mirroring or backups, then the analysis I/O can be worse than the file transfer I/O –  Mark Porter Mar 16 '10 at 19:00

Run the suggested -STOP and -CONT as part of some screen-saver maybe?

(If you're on a terminal: There's also a screen-saver for terminals, but I don't know its name, or where to set its options. All I know is, that it's on by default on Ubuntu :-)

share|improve this answer

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.