LPI 101-500 – 103.6: Change process execution priorities
July 23, 2023

1. nice, renice, ps, top

This lesson is about the socalled Nice value, which I mentioned in previous videos. To explain the Nice value, maybe let’s open Top and in the fourth column from the left here in this one we see the Nice value. It is a priority given to a process. The better the Nice value in quotes, the more cpu power this process receives. Suppose we have a system that is busy or even overloaded by various tasks. Now the company board has to print something very important and the print has to go through immediately. Then you can use the Nice command to increase the priority of the print process, so that this process receives more computing power and can therefore be started directly.

All processes have preset Nice value. The standard value is zero. The range of values ranges from -20 to plus 19 with -20 being the best value so the value that receives the most computing power. And the highest priority plus 19 is the worst Nice value. This process is accordingly given the lowest priority and therefore the least computing power. Even normal users can change the Nice value of an own process, but this is only entitled to the values zero to 19, the minus values. So the values with the higher priority can only be changed by root. We can start our already known sleep command with a Nice value of five. To do this I leave top again or left top again.

And the command works as follows nice with the option n five for the Nice value of five, and then Sleep 1000 and we want to open or to run it in the background. So with Top we can now check in which Nice level sleep is running. So I use Top with the option p and with this process ID 6143 and here we see here is the Sleep command and it has the Nice value five. If we use the Nice command without a value, the Nice value ten is assigned by default. For example Nice Sleep 2000 and let’s check it again with Top p and then 6150. And we see. We have here the sleep command and it has the Nice value ten. The Nice command only works if we enter it directly when starting the program.

If the program is already running, Nice no longer works and we have to use the command re Nice. So let’s check for our sleep commands pscfgraph sleep and here we have Sleep 1000, Sleep 2000 and let’s change the Nice value of the process ID 6150. So the Sleep 2000 process, which we gave the Nice value ten, we want to use now a Nice value of two. So we use the following command pseudo RENAISS two for the Nice level two and we use the option p and the process ID 6150 have to enter my password. And here you can see old priority ten, new priority two with Re Nice, the option N, which we always introduced with nice for a new Nice value is not necessary.

We assign the sleep command again pseudo renoisse and as I said, you don’t have to use the option n. You can simply put in the Nice value. Here I used two. Now let me choose minus ten and then p and then again the process ID 6150 and here we get the answer. Old priority two. New priority minus ten. So it now has a much better priority than before. Of course there are also options at real Nice. For example, with the option U for users, you could ensure that all processes of a user receive a certain Nice value. For example, pseudo RENAISS one. So the Nice value one and the option u for users. And I use the user manual. Old priority minus eleven. New priority one so with top we can see here at the top there are some processes of manual and they all have the Nice value one.

You can see the Nice value of a process not only via top, but also via ps. For this we would use the following command psef and then o and then PID ni CMD in addition to Psef, we also use the O option, which ensures that we can define the columns of the displayed table ourselves. The corresponding abbrevations for the columns can be found in the Psman page. In that case I choose the column PID for process ID, ni for Nice value and CMD for the corresponding command. Now I can see see the process ID, the Nice value and the corresponding commands. So here are the commands, here are the Nice values and here are the process ids.

Leave a Reply

How It Works

img
Step 1. Choose Exam
on ExamLabs
Download IT Exams Questions & Answers
img
Step 2. Open Exam with
Avanset Exam Simulator
Press here to download VCE Exam Simulator that simulates real exam environment
img
Step 3. Study
& Pass
IT Exams Anywhere, Anytime!