0348-0350.html

来自「linux-unix130.linux.and.unix.ebooks130 l」· HTML 代码 · 共 214 行

HTML
214
字号




<HTML>

<HEAD>

<TITLE>Developer.com - Online Reference Library - 0672311739:RED HAT LINUX 2ND EDITION:Advanced System Administration</TITLE>

<META NAME="ROBOTS" CONTENT="NOINDEX, NOFOLLOW">
<SCRIPT>
<!--
function displayWindow(url, width, height) {
        var Win = window.open(url,"displayWindow",'width=' + width +
',height=' + height + ',resizable=1,scrollbars=yes');
}
//-->
</SCRIPT>
</HEAD>

 -->




<!-- ISBN=0672311739 //-->

<!-- TITLE=RED HAT LINUX 2ND EDITION //-->

<!-- AUTHOR=DAVID PITTS ET AL //-->

<!-- PUBLISHER=MACMILLAN //-->

<!-- IMPRINT=SAMS PUBLISHING //-->

<!-- PUBLICATION DATE=1998 //-->

<!-- CHAPTER=16 //-->

<!-- PAGES=0341-0350 //-->

<!-- UNASSIGNED1 //-->

<!-- UNASSIGNED2 //-->









<P><CENTER>

<a href="0345-0347.html">Previous</A> | <a href="../ewtoc.html">Table of Contents</A> | <a href="../ch17/0351-0354.html">Next</A>

</CENTER></P>



<A NAME="PAGENUM-348"><P>Page 348</P></A>











<P>have not been used for a while so that when the memory is needed, it is available. The

system will not have to wait for the memory to be swapped out.

</P>









<H3><A NAME="ch16_ 6">

Momma Always Said to Be Nice!

</A></H3>









<P>I grew up with two older brothers and one younger one. There were many times when

Momma said to one or more of us to be nice! Sometimes the same is true for our processes. The

renice command is used to alter the priority of running processes.

</P>









<P>By default in Red Hat Linux, the nice value is

0. The range of this is _20 to 20. The lower the value, the faster the process runs. The following example shows how to display the

nice value by using the nice command. My shell is running at the default value of

0. To check this another way, I issue the ps -l command. The

NI column shows the nice value:</P>





<!-- CODE //-->

<PRE>

shell:/home/dpitts$ nice

0

shell:/home/dpitts$ ps -l

 FLAGS   UID   PID  PPID PRI  NI   SIZE   RSS WCHAN       STA TTY TIME COMMAND

   100   759  3138  3137   0   0   1172   636 force_sig   S   p0  0:00 -bash

100000   759  3307  3138  12   0    956   336             R   p0  0:00 ps -l

</PRE>

<!-- END CODE //-->











<P>I change the nice value by using the renice command. The syntax of the command is as 

follows:</P>





<!-- CODE SNIP //-->

<PRE>

renice priority [[-p] pid ...] [[-g] pgrp ...] [[-u] user ...]

</PRE>

<!-- END CODE SNIP //-->











<P>In the following example, the shell's nice value is changed to a value of

5. This means that any process with a lower value will have priority on the system.</P>





<!-- CODE //-->

<PRE>

shell:/home/dpitts$ renice 5 3138

3138: old priority 0, new priority 5

shell:/home/dpitts$ nice

5

shell:/home/dpitts$ ps -l

 FLAGS   UID   PID  PPID PRI  NI   SIZE   RSS WCHAN       STA TTY TIME COMMAND

   100   759  3138  3137   5   5   1172   636 force_sig   S N p0  0:00 -bash

100000   759  3319  3138  14   5    968   368             R N p0  0:00 ps -l

</PRE>

<!-- END CODE //-->











<P>The owner of the process (and root) has the ability to change the

nice value to a higher value. Unfortunately, the reverse is not also true:

</P>





<!-- CODE SNIP //-->

<PRE>

shell:/home/dpitts$ renice -5 3138

renice: 3138: setpriority: Permission denied

</PRE>

<!-- END CODE SNIP //-->











<P>Only root has the capability to lower a nice value. This means that even though I set my

shell to a nice value of 5, I cannot lower it even to the default value.

</P>









<P>The renice command is a wonderful way of increasing the apparent speed of the system

for certain processes. This is a trade-off, though, because the processes that are raised will now

run slower.

</P>



<A NAME="PAGENUM-349"><P>Page 349</P></A>













<H3><A NAME="ch16_ 7">

Summary

</A></H3>









<P>Computers slow down significantly when they run out of memory. Also, if they try to do

too much at one time, they seem slow. As a system administrator, your job is to determine

whether the system is really slow or just seems slow. The difference is significant. If the system

seems slow, the problem is usually a matter of adjusting the times certain processes are run.

Using cron and at helps to schedule certain activities when the system is otherwise idle.

</P>









<P>If the system is really slow, that is, waiting on processes all the time, with consistent IO

waits, then it is time to invest in more equipment. The other option is to just live with it. (Get

your users to buy off on that one!) As system administrator, your job is to keep performance at

an acceptable level. With tools such as vmstat and

top, this task is much simpler.

</P>









<P>Sacrificing speed in certain processes is another way of increasing the apparent speed of

other processes. The basic concept is that each process gets a certain piece of the processing pie.

Certain processes can have a smaller, or root can give them a larger, piece of the processing pie.

The amount of processing that can be completed never changes. The change is in how much

processing time each process gets. Mainframes call this

cycles. The lower your nice value, the more cycles you get each time the processor comes to do your work.

</P>



<A NAME="PAGENUM-350"><P>Page 350</P></A>













<P><CENTER>

<a href="0345-0347.html">Previous</A> | <a href="../ewtoc.html">Table of Contents</A> | <a href="../ch17/0351-0354.html">Next</A>

</CENTER></P>









</td>
</tr>
</table>

<!-- begin footer information -->





</body></html>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?