17

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?

1 Answer 1

24

This is pretty trivial.

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