Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

When I renice a multithreaded process in Ubuntu 10.04, then view the results in top, it seems that only the main thread actually gets reniced. All the other threads retain their old nice value. What's the easiest way to renice all threads in a process instead of just the main thread?

share|improve this question
up vote 7 down vote accepted

renice +/-n -g gid

gid is the process group id which you can find with ps -Aj

share|improve this answer

The following command can set the nice value to +15 for all threads in process "procid":

ps --no-heading -Lj <procid> | awk '{system("renice +15 "$4)}'
share|improve this answer

Inspired by zhihui's answer, what I actually used:

renice -n <niceness> -p `ps --no-heading -Lo tid <PID>`
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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