Time
8 hours 30 minutes
Difficulty
Beginner
CEU/CPE
10

Video Transcription

00:02
All right, so in Section 123.6, we're going to look at modifying
00:07
process priorities.
00:10
We're nearly done with module one of three. Just a few more sections to go
00:15
anyway. So when a process runs, it gets a default. Nice value. The nice value is a way to specify the relative priority of a given process compared to everything else.
00:27
So we can change this.
00:29
We could inspect the value. We can also change it,
00:33
and we saw that already
00:35
with the top command.
00:39
We'll review that here again.
00:42
But Top lets me very easily looking a process list and just hit our for re nice
00:48
to change the nice value.
00:50
I can
00:51
examine the current nice value setting of a process by running PS dash yell. There's other ways to see it as well,
00:59
and I could see what my current value is
01:02
when I just run nice by itself. No,
01:04
no arguments
01:10
Now, if I'm launching a process from scratch and I know for sure that I want to give it a certain priority, I can do it on the command. Unlike we see here,
01:18
Nice dash end tells me
01:21
which gives me the option to specify a priority.
01:25
And then I just specify the command.
01:27
Negative values give a highest priority. So, uh, Dash 20 negative 20 is the lowest number we can specify here. Which
01:37
inversely means that it has the highest priority on that system.
01:41
19 would be the lowest priority.
01:44
So if I'm sorry about that, if I'm using a Valium 19 that means this process is not very important. Take the least amount of resource is to continue to operate.
01:55
So let's
01:57
see what this looks like.
01:59
Very easy to use these commands.
02:02
It's clear my screen.
02:07
Okay? I don't have any process. He's running right now. I don't have any jobs running right now,
02:10
so I'm gonna specify
02:17
a job of, uh,
02:21
another sleep job.
02:23
Now, I will run PS, dash E l
02:25
and great for sleep.
02:29
And we can see that 40359 actually might have been
02:34
I should have just grabbed for the, uh,
02:36
process I d. Number
02:38
in the eighth column is my nice value. So this
02:43
sleep process has a high priority right now.
02:46
And I could I could run a, uh,
02:51
another sleep process with a plus 10 priority, which read as much lower
02:57
and I can grab for that process. I d number 403
03:00
94
03:02
And there's it's nice value.
03:07
So I can see it right from the command line or we run it from top
03:13
and
03:16
freak apologised. You sleep because I don't remember what the p I. D was.
03:23
But there's my nice values being shown here.
03:27
So 40359
03:29
I can hit the r key, and that happens to be at the top of the list.
03:32
So go from negative 10 to negative 20 which is the highest possible priority.
03:51
Ah, negative. 20.
03:53
Very good.
03:55
Now that one showed up. There it is that one shows up with the highest priority.
04:00
So pretty useful.
04:01
Now, what do I do if I've got a process that is running at a certain priority and I decided that I want to change it, I can use the re nice command,
04:11
so I just given a value
04:13
and I could do this at the user in the group level as well, which is kind of nice,
04:17
because sometimes that may be more appropriate.
04:23
So
04:25
40359 should still be that running process for for sleep.
04:30
Oops. I won. I won a ps dash Yell for this. Sorry.
04:35
And there's my negative 20. Nice value.
04:40
So I can use re nice.
04:43
I say that I want
04:44
I want to make this a plus 10. Nice value because it's going from very high priority to very low priority.
04:54
Old priority minus 20. New priority 10.
04:58
So this is very easy to use.
05:00
If I type nice by itself, I get my default value, which is currently 20. You can configure that if if you want to change it,
05:10
I could also, um,
05:24
you have been
05:26
Here we go.
05:27
So these are all my admin processes and I can see in that eighth column
05:31
that I'm Here's one
05:34
Ah, pulse Audio. This has a
05:39
a p i D of 2024
05:46
green eyes
05:47
dash, and I'll give it a priority of
05:51
minus five.
06:00
So very simple to do this.
06:05
So get familiar with these commands. They are occasionally very useful when you wanted
06:10
juggle things around and allocate more resource is for certain things that are taking too long or that you want to finish sooner
06:16
and also be able to take other processes and put them in the background because their completion time is not is critical.
06:24
All right, that gets us to the end of this section or next topic is searching files with regular expressions.
06:30
See you there. Thank you.

Up Next

CompTIA Linux+

Our self-paced online CompTIA Linux+ course prepares students with the knowledge to become a certified Linux+ expert, spanning a curriculum that covers Linux maintenance tasks, user assistance and installation and configuration.

Instructed By

Instructor Profile Image
Dean Pompilio
CEO of SteppingStone Solutions
Instructor