In a Linux system, there are hundred’s of processes, that are continuously running diffrents tasks. Linux Kernel does a fantastic job in mediating between these processes and allotting CPU to these processes.
Every running process in Linux has a priority assigned to it.We can change the process priority using nice and renice utility.
With the help of Nice command in Linux you can set process priority. If you give a process a higher priority, then Kernel will allocate more cpu time to that process.
Nice command will launch a process with an user defined scheduling priority. Renice command will modify the scheduling priority of a running process.Linux Kernel schedules the process and allocates CPU time accordingly for each of them.
he process scheduling priority range is from -20 to 19. We call this as nice value.
A nice value of -20 represents highest priority, and a nice value of 19 represent least priority for a process.
Follow the below process to increse the priority of any process.
1 ) Login into your Linux system via user name and password , enter # top command.
After hiting enter you will get output like above screen, in that NI means Nice Value of perticular prcess .
2 ) We can set NI value of any process or command in 2 way.
i ) In the outout of # top command , just enter ” r ” , we get the screen like below.
By default when a programe is launched in Linux, it gets launched with the priority of ‘0’. However you can change the priority of your service yourself.
Simply just put the PID of any process , or the PID of that process which you want to increse the priority. Hit enter after putting PID.
It will ask for Renice value , see the above screen. put the value priority range is from -20 to 19. We call this as nice value.A nice value of -20 represents highest priority, and a nice value of 19 represent least priority for a process.
After putting renice value , the process priority will change accodring to NI value.
check the NI coloum after purring renice value of any process , see below screen
In the above screen PID of kthreadd is 2 and its nice valur has been changed to -10 , means now it has higher priority among then all process , which is running under Linux system.
We can also set the NI nice value of any process like httpd, java , mysql , ftp , sshd to make that service perform fast.
ii ) We can set NI via another way , by using simple below command
After top command , do the below step to increase performance of any service, or process
# nice -10 httpd
Above commmand will set NI valur of httpd service to 10 , means it has lower priority among all the running process under linux system.
# nice –10 httpd
Above command will set Ni value of httpd service to -10 , means it has highest priority , we can incresre this value ti -20 , A nice value of -20 represents highest priority.