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


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


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?


This is pretty trivial.

renice -n 10 $$
  • Sure, that is it. In some systems, -n is not accepted. – blueFast Sep 14 '12 at 13:51
  • 2
    For those who don't know, $$ is the current shell process ID. – Daniel F Mar 1 '19 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.