MacOS – How to renice by process name

command linemacos

I am trying to Launch a process using NICE but this process is starting other process by itself and they are not affected by the priority of the main process ( main process has the correct nice but sub process priority is set to default)

So I am trying to renice those process while they run.
I tried

 renice n -p $(pidof <process name>)

but it is not recognised by MacOS (it is probably linux specific ?)
so how can I do that?

you can find a related discussion here:
https://stackoverflow.com/questions/30062340/starting-process-with-nice-command-macos-leaves-the-process-priority-at-0#comment48287323_30062340

thanks.

Best Answer

You can use pgrep instead of pidof on OS X. Using your example from earlier, the following should work:

renice n -p $(pgrep <process name>)

That said, a child started after the parent has had their priority changed should inherit the parent's priority.