4

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.

  • :renice is not a command line program I don't think any begin with : I suspect the format of that question is confusing - I have edited t to make it clearer – user151019 May 7 '15 at 19:11
  • Sorry for the typo, it is edited – MSH May 7 '15 at 20:19
  • I see no need for downvotes. – CousinCocaine May 7 '15 at 20:35
5

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.

  • Yes... well It seems that After effect command line render starts aerenderCore as a "child" process. and it is not affected by the priority of its parents. I still have to test you code line, I'll be back! – MSH May 8 '15 at 20:25
2

There are multiple correct answers, here an answer let suits your train of thought.

Run this oneliner:

renice 10 -p $(ps -ax | grep -i [p]rocessname | awk 'NR==1{print $1}')

What is does:

  • renice 10, this will make your process run with the nicety of ten, the nicer, the higher the number.
  • -p expects the process id
  • ps -ax lists all running processes with there name and PID
  • grep -i [p]rocessname only matches the processes with 'processname', case insensitive. the brackets will prevent to match the grep process itself.
  • awk 'NR==1{print $1}' will fetch the 1st instance (NR==1) of the first column ($1)

You already gave a good example of command substitution.

  • Actually 10 is lower, -10 is higher, a higher value lowers the process priority to make it nicer – eXa Nov 22 '17 at 23:30

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .