bashprocessnice

To renice the process paused with Control-Z


I want to renice the process that I just stopped using Control-Z without looking through the output of top or ps. I know you can resume a process, or a job in terms of Bash to be precise, like bg 1 for example. But can you do something like that for renice?


Solution

  • You can get the PID of stopped job by providing its jobspec to jobs builtin, and use it as an argument to renice. E.g:

    $ sleep 10
    ^Z
    [1]+  Stopped                 sleep 10
    $ renice -20 $(jobs -p %1)
    26939 (process ID) old priority -11, new priority -20
    $