Skip to main content
LPIC-1 Exam 101

Using nice and renice to modify execution priorities

By June 8, 2014September 12th, 2022No Comments

Getting ready for the exam 117-101 from the Linux Professional Institute LPIC-1 101 we look at using nice and renice to modify the CPU time for an application.When a command begins in Linux is is assigned a priority to talk with the the CPU, by default this is 80. The lower the priority the less CPU time is assigned to the application. We can adjust the priority using the nice command when an application starts or later with the renice command. The assigned nice value has a direct affect on the application priority. In Linux the nice value is adjustable from -20 to +19. The lower the nice value the lower the priority and consequently the more CPU time is assigned.  The default nice value of 0 assigns the priority of 80 to the application. The can be seen with ps -l.

Only root can set negative nice values.

nice -n 10 sleep 100

The above command will start the sleep command with a nice value of 10 and a priority os 90.

renice -n 19 3167

The above command will change the nice value of the process 3167 to 19. 19 is the highest value and has a priority of 99.