1
00:00:06,580 --> 00:00:11,385
We already talked about changing process priority
while discussing top, but you don't need top

2
00:00:11,385 --> 00:00:16,190
to change process priority. Let's check out
how to do it from the command line.

3
00:00:17,289 --> 00:00:20,440
By default, user processes are
started with the same priority.

4
00:00:21,140 --> 00:00:24,989
And to adjust priorities, users
can use the nice command.

5
00:00:26,399 --> 00:00:29,879
Non privileged users can only
run processes with a lower priority.

6
00:00:30,519 --> 00:00:35,030
And privileged users can increase
and decrease process priority as well.

7
00:00:35,689 --> 00:00:39,864
And the reach is from
minus 20, which is the highest

8
00:00:39,864 --> 00:00:44,039
priority, to positive 19, which
is giving you the lowest priority.

9
00:00:45,159 --> 00:00:50,579
And if you want to change the priority for
currently running processes, you would use the renice command.

10
00:00:51,689 --> 00:00:53,719
We already have seen how
to do it from top.

11
00:00:54,359 --> 00:00:57,649
Now let's change some
priorities from the command line.

12
00:00:59,009 --> 00:01:02,240
So I'm going to
use sudo nice help.

13
00:01:04,750 --> 00:01:10,549
Of course you don't need sudo to get
help, but what I'm looking for is the syntax.

14
00:01:11,269 --> 00:01:15,510
So in the syntax you can
see N N is the adjustment.

15
00:01:16,090 --> 00:01:21,200
Okay, so that means
that I'm going To use

16
00:01:21,200 --> 00:01:26,310
sudo nice n10 dd
if is dev 0 of

17
00:01:26,310 --> 00:01:31,420
is dev null
running as a background.

18
00:01:32,099 --> 00:01:38,140
And let's also do another priority,
same command, sudo nice n minus 10.

19
00:01:40,599 --> 00:01:44,510
And then still the best way
to figure out would be top.

20
00:01:45,209 --> 00:01:47,980
But hey, can we also
see it from another perspective?

21
00:01:49,000 --> 00:01:54,873
Figure it out. Psaox pipe
grab DD and there we can

22
00:01:54,873 --> 00:02:00,746
see these DD processes to
give you the cycles anyway. And

23
00:02:00,746 --> 00:02:06,620
that's why you can see
them having the same CPU percentage.

24
00:02:07,379 --> 00:02:12,514
So the first DD process
with PID 6351 has the PR

25
00:02:12,514 --> 00:02:17,649
set to 3030 and the
nice value set to 10.

26
00:02:18,409 --> 00:02:22,384
So that's the friendly process. The other
one has the PR set to 10

27
00:02:22,384 --> 00:02:26,360
and a nice value set to
minus 10. And that's the unfriendly process.

28
00:02:27,539 --> 00:02:30,819
You can also change
priority on running processes.

29
00:02:32,479 --> 00:02:38,159
So let me use dd
if is dev0 of is

30
00:02:38,159 --> 00:02:43,840
device dev null again
as a background job. Oops.

31
00:02:47,240 --> 00:02:53,689
So running jobs to verify that it is actually
running. And I'm looking for job number five here.

32
00:02:54,310 --> 00:02:56,599
And that is the
one that we're talking about.

33
00:02:57,419 --> 00:03:03,709
And what happens if we see
it in top? Well, I can see

34
00:03:03,709 --> 00:03:10,000
the student job which is running
with a CPU percentage of almost 100.

35
00:03:11,129 --> 00:03:16,623
Now if I want to
change the priority for that,

36
00:03:16,623 --> 00:03:22,116
then first I need PS
A and PS A is

37
00:03:22,116 --> 00:03:27,610
showing not enough information
psaux Anyway, pipe grab dd.

38
00:03:28,110 --> 00:03:30,909
Now let's start again with if
I want to change the priority.

39
00:03:32,469 --> 00:03:36,469
If I want to change the priority,
I need to remember the process id 6685.

40
00:03:38,469 --> 00:03:44,034
Let me quit top
and let me use renice

41
00:03:44,034 --> 00:03:49,599
minus n19 on pid
6685 there we can see

42
00:03:49,599 --> 00:03:55,164
that it has rescheduled
the priority. The old priority

43
00:03:55,164 --> 00:04:00,729
was zero and the
new priority is 19.

44
00:04:02,090 --> 00:04:04,949
That is how you can
manage priority from the command line.

45
00:04:05,860 --> 00:04:10,014
Let's not forget to do a
sudokel all DD because otherwise we

46
00:04:10,014 --> 00:04:14,169
have too many processes that are
being quite busy on this system.
