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

1
  • At a text console or X?
    – James
    Mar 31, 2010 at 22:34

5 Answers 5

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>
1
  • This doesn't tell me how to detect if there is console activity, which is the more tricky part AFAIK. Mar 31, 2010 at 19:19
2

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

3
  • linux.die.net/man/1/nice
    – Zoredache
    Mar 16, 2010 at 17:51
  • 2
    You'll probably want to use 'ionice' if it's disk bound, rather than 'nice'
    – James
    Mar 16, 2010 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. Mar 16, 2010 at 19:03
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
0

rsync has a --bwlimit option.

1
  • 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 Mar 16, 2010 at 19:00
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 :-)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .