11

I would like to change the nice level of the currently running script:

#!/bin/bash

nice_it ( ) {
    nice
    ps -o "%p %r %y %x %n %c %a"
}

nice_it

That does not work, since nice tries to change the nice level of the command started by it.

Is it possible to achieve this in bash?

18

This is pretty trivial.

renice -n 10 $$
  • Sure, that is it. In some systems, -n is not accepted. – dangonfast Sep 14 '12 at 13:51
  • For those who don't know, $$ is the current shell process ID. – Daniel F Mar 1 at 11:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.