Wednesday, August 26, 2009

renice a process by name on mac or *nix

The nice value of a process indicates the priority of that process as seen by the kernel's scheduler.

You can see the nice value of your processes by running:

ps -eo pid,nice,command | grep YourProcessName | grep -v grep



If you want to change a process' scheduling priority you can use renice:

renice -n 20 -p `ps -eo pid,command | awk '/YourProcessName/ && !/awk/ {print $1}'`



Usually a process can have a nice value within the range of of -20 (the highest) to 20 (the lowest). But you want to 'man nice' on your OS to make sure.

I was doing this in reference to this responseless thread I started to throttle handbrake's cpu usage


But changing the nice value of the HandBrake process did not work. HandBrake still takes over the CPU. I now plan to write a utility that sends HandBrake SIGSTOP and SIGCONT based on it's CPU usage. Lets see how that works.

1 comment:

  1. changing the priority have nothing to do with preventing handrbrake from consuming the cpu.

    but is you lower the priority of handbrake, and another process needs cpu, this process will get it, cause the scheduler will allow more cpu times to this process than to handbrake.

    but when noone else than handbrake requires it, handbrake can take all the cpu.

    this is an all win strategy.

    ReplyDelete