Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to renice a PID dynamically?

Tags:

bash

On our development server, we have a bunch of shell script wrappers for Java JARs. Using the CRON scheduler, we do fire these scripts daily for different purposes.

For performance testing, we would like to renice a script's PID to a priority of 1 at runtime.

Right now, we do it from the command line or using TOP.

Is there a way to do that within the shell script itself without "doing harm" to the process as well as other processes?

like image 518
Chris Avatar asked Dec 30 '25 20:12

Chris


1 Answers

This should work:

renice -n 1 $$

Afterwards the script itself will have a nice value of 1. This will also apply to all new children, although not to previously forked ones.

like image 189
Eduardo Ivanec Avatar answered Jan 01 '26 14:01

Eduardo Ivanec



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!