Renice command with input argument as a file

Hi all

could you help me how to give pids in a file as an argument to renice command.

Thanks in Advance.. :slight_smile:

Pradeep

Use a while loop to read each PIDs from your input file into a variable and use that variable:

while read pid
do
   renice <inc> -p "$pid"
done < inputfile

hey thanks for replying,

i used the same command, got the below error, please suggest.

line 3: inc: No such file or directory.

---------- Post updated at 09:54 AM ---------- Previous update was at 09:50 AM ----------

i have redirected all the pids to a file name nice,

created a script inthe file called script.
script is :

while read pid
do
renice <inc> -p "$pid"
done < nice

Please suggest if i missed some thing

Replace <inc> with your nice value.

Check renice manual for further reference.

thanks a lot dude... it worked. I forgot to add value...

I have another issue as well.. will be able to help me on that aswell ...

main issue am facing is,

  1. few applications are starting with nice -20 as default instead of 0,
  2. Also 2 users are getting started all apps with -20 instead of 0.

am not able to fix this checked my scripts, everything is the same.

as a temporary fix i am grepping the pids and using renice command manually (now using the script you gave).

can you help to fix it manually..

Thanks in advance..