You are not logged in.
Pages: 1
Hi all,
I was wondering if there was any way to recursively set nice priorities on a process. By default, when you "nice" a process, it doesn't change the priorities of its children. So is there way to do so without heavy scripting? Or would any of you have such a script at their disposition?
Autojump, the fastest way to navigate your filesystem from the command line!
Offline
$ ps --ppid YOUR_PID | grep -v "PID" | awk '{print $1}' | xargs nice -YOUR_NICE_VALUE YOUR_PID
I think that will do it. Just list all of the process's children, then parse the pid's out and send them into nice.
[edit]
Added the YOUR_PID on the end so that this would effect the parent process as well.
Last edited by B-Con (2008-09-23 04:53:10)
Offline
$ ps --ppid YOUR_PID | grep -v "PID" | awk '{print $1}' | xargs nice -YOUR_NICE_VALUE YOUR_PID
That doesn't work because it stops at the direct children of the process you pass in, so it's not recursive.
Autojump, the fastest way to navigate your filesystem from the command line!
Offline
OK, then, do:
function rnice {
nice -n $1 $2
for child in $(ps --ppid $2 -o pid=); do
rnice $1 $child
done
}
Offline
Pages: 1