Unix command to suspend a job while there is console activity?

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>

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


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