nice and renice Command In Linux

nice command is used to modify scheduling priority of some running command or application. If we give a process a higher priority, then Kernel will allocate more CPU time to that process.

There are two terms which one should pay attention.

Priority Value  : 

The priority value is the process’s actual priority which is used by the Linux kernel to schedule a task.
In Linux system priorities are 0 to 139 in which 0 to 99 for real-time and 100 to 139 for users.

Nice Value :

Nice values are user-space values that we can use to control the priority of a process. The nice value range is -20 to +19 where -20 is highest, 0 default and +19 is lowest.

The relation between nice value and priority is as such –

Priority_Value = Nice_Value + 20 

In above picture you can see both – Priority and Nice Level.

You can also check the same with

# ps -elx

■   Setting Priority of running process 

# nice -10 /usr/sbin/httpd

■   Assign negative Priority of running process 

# nice --10 /usr/sbin/httpd

■   Change nice level of running process.

# renice -n 15 -p 1260
1260 (process ID) old priority 0, new priority 15