5

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.]

5 Answers5

4

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>
mdeous
  • 398
  • 3
  • 11
2

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

Alex
  • 253
2

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
Mark Porter
  • 1,051
0

rsync has a --bwlimit option.

0

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 :-)

Chris Lercher
  • 4,412
  • 9
  • 38
  • 41