How To Use nice and renice in Linux

Linux system have capability to run many process simultaneously. By default all process have equal value and linux provide equal CPU time to each process. It assumed that all process are urgent.  Linux provide a facility to user that they can change the priority according to their requirement. By default the priority of process is 0. nice is used to set process priority in linux.A process priority value range from -20 to 19 .  Process with the nice value -20 is considered to be on top of the priority and a process with the nice value 19 is considered to be on low of the priority. In this short article i will explain how to use nice and renice in linux .

How we can see the priority of process :-

To see the priority of process, you can use top command. First we check through top command . The output of this command is

top commandAs we can see the output of top command , there are many things that shows on this output.  Here we can see the load average , total swap memory , total memory , total running process, free space , used space , users and many more other information .

How we can set the priority of a process:-

To set the priority of a process we use nice command with some option. The basic syntax   is given below :-     
Suppose we have to set a process with priority 10. To set this we can use,        

How we can renice a process :-

renice is used to change the priority of process that is already running. There are some example given below :

When you run similar command that given above , the output comes like –


you can also renice a process through top command . After running top command in your terminal , just press . When you press r , the output commes on the screen looks like given below –

when you enter PID , which you want to renice. It asked you for renice value of your PID.

nice and renice in linux

So in this short artice , i explained you about how to use nice and renice in linux .  Please subscribe to newsletter for updated articles. We will discuss about many other topics in next articles.