old-www/LDP/lame/LAME/linux-admin-made-easy/managing-processes.html

309 lines
6.3 KiB
HTML

<HTML
><HEAD
><TITLE
>Managing Processes</TITLE
><META
NAME="GENERATOR"
CONTENT="Modular DocBook HTML Stylesheet Version 1.63
"><LINK
REL="HOME"
TITLE="Linux Administration Made Easy"
HREF="index.html"><LINK
REL="UP"
TITLE="Various & Sundry Administrative Tasks"
HREF="various-and-sundry.html"><LINK
REL="PREVIOUS"
TITLE="Checking Storage Space"
HREF="checking-storage-space.html"><LINK
REL="NEXT"
TITLE="Starting and Stopping Processes"
HREF="redhat-processes.html"></HEAD
><BODY
CLASS="SECT1"
BGCOLOR="#FFFFFF"
TEXT="#000000"
LINK="#0000FF"
VLINK="#840084"
ALINK="#0000FF"
><DIV
CLASS="NAVHEADER"
><TABLE
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TH
COLSPAN="3"
ALIGN="center"
>Linux Administration Made Easy</TH
></TR
><TR
><TD
WIDTH="10%"
ALIGN="left"
VALIGN="bottom"
><A
HREF="checking-storage-space.html"
>Prev</A
></TD
><TD
WIDTH="80%"
ALIGN="center"
VALIGN="bottom"
>Chapter 9. Various &#38; Sundry Administrative Tasks</TD
><TD
WIDTH="10%"
ALIGN="right"
VALIGN="bottom"
><A
HREF="redhat-processes.html"
>Next</A
></TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><DIV
CLASS="SECT1"
><H1
CLASS="SECT1"
><A
NAME="MANAGING-PROCESSES"
>9.2. Managing Processes</A
></H1
><P
>From time to time you may wish to view processes that are running
on Linux. To obtain a list of these processes, type ``<TT
CLASS="LITERAL"
>ps
-aux</TT
>'', which will look similar to the following:</P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><PRE
CLASS="SCREEN"
>USER PID %CPU %MEM SIZE RSS TTY STAT START TIME COMMAND
bin 69 0.0 1.0 788 320 ? S Nov 30 0:00 /usr/sbin/rpc.portmap
frampton 10273 0.0 2.1 1136 664 p0 S 14:12 0:00 -bash
frampton 10744 0.0 1.1 820 360 p0 R 17:25 0:00 ps -aux
frampton 10745 0.0 0.8 788 264 p0 S 17:25 0:00 more
nobody 10132 0.0 1.8 1016 588 ? S 13:36 0:00 httpd
nobody 10133 0.0 1.8 988 568 ? S 13:36 0:00 httpd
nobody 10413 0.0 1.8 1012 580 ? S 14:56 0:00 httpd
nobody 10416 0.0 1.8 1012 580 ? S 14:56 0:00 httpd
nobody 10418 0.0 1.8 1012 588 ? S 14:57 0:00 httpd
nobody 10488 0.0 1.7 976 556 ? S 15:34 0:00 httpd
nobody 10564 0.0 1.8 988 564 ? S 16:06 0:00 httpd
nobody 10600 0.0 1.8 988 564 ? S 16:15 0:00 httpd
nobody 10670 0.0 1.8 988 568 ? S 16:45 0:00 httpd
nobody 10704 0.0 1.7 976 552 ? S 17:03 0:00 httpd
root 1 0.0 1.0 776 312 ? S Nov 30 1:13 init [3]
root 2 0.0 0.0 0 0 ? SW Nov 30 0:00 (kflushd)
root 3 0.0 0.0 0 0 ? SW Nov 30 0:00 (kswapd)</PRE
></TD
></TR
></TABLE
><P
>The list shows you the owner of the process (<SPAN
CLASS="QUOTE"
>"nobody"</SPAN
>
for special services such as web servers), the process identification
number, the % of CPU time the process is currently using, the % of memory
the process is consuming, and other related information, as well as a
description of the task itself.</P
><P
>To get more information on a given process, type ``<TT
CLASS="LITERAL"
>ps
<TT
CLASS="OPTION"
>pid</TT
></TT
>'' (where
<SPAN
CLASS="QUOTE"
>"<TT
CLASS="LITERAL"
><TT
CLASS="OPTION"
>pid</TT
></TT
>"</SPAN
> is the process
identification number). Looking at our example above, <SPAN
CLASS="QUOTE"
>"<TT
CLASS="LITERAL"
>ps
10704</TT
>"</SPAN
> would display:</P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><PRE
CLASS="SCREEN"
>10704 ? S 0:00 /usr/local/etc/httpd/httpd</PRE
></TD
></TR
></TABLE
><P
>This would tell you that this particular process is a web server (the
Apache web server appears multiple times in the process list; for
information on why see <A
HREF="web-server-administration.html"
>Section 7.1</A
>).</P
><P
>If you happen to notice a service is not operating, you can use the
<SPAN
CLASS="QUOTE"
>"<TT
CLASS="LITERAL"
>kill -HUP <TT
CLASS="OPTION"
>pid</TT
></TT
>"</SPAN
> (where
<SPAN
CLASS="QUOTE"
>"<TT
CLASS="LITERAL"
><TT
CLASS="OPTION"
>pid</TT
></TT
>"</SPAN
> is the process
identification number as shown in the process list produced with
<SPAN
CLASS="QUOTE"
>"ps"</SPAN
>). For example, if Internet services (a process called
inetd, process #123 in our example) are not working as they should, a
``<TT
CLASS="LITERAL"
>kill -HUP 123</TT
>'' (or even safer, use the
``<TT
CLASS="LITERAL"
>killall</TT
>'' command and specify the process name:
``<TT
CLASS="LITERAL"
>killall -HUP inetd</TT
>'') should restart the process.
The <TT
CLASS="OPTION"
>-HUP</TT
> option to the kill command means <SPAN
CLASS="QUOTE"
>"hang
up"</SPAN
>; the process knows that it is supposed to reload itself.</P
><P
>Another thing to try if you are unable to resolve the problem would
be to shut the system down and reboot it (see <A
HREF="system-shutdown-and-restart.html"
>Section 6.7</A
> for details).</P
><P
>At times, you may find it necessary to temporarily suspend a
process, and then resume its execution at a later time. For example,
you may be running a CPU-intensive job and wish to burn an IDE-based
CDRecordable. Since IDE-based devices rely on the CPU for much of the
work behind input/output, they are prone to buffer starvation if your
CPU is too busy, and you end up with a useless coaster instead of a
properly prepared CD! The following two commands will suspend a process,
and the resume it, respectively:</P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><PRE
CLASS="SCREEN"
>kill -STOP 945
kill -CONT 945</PRE
></TD
></TR
></TABLE
><P
>Red Hat provides a better way of starting and stopping some processes,
which are covered in <A
HREF="redhat-processes.html"
>Section 9.3</A
> below.</P
></DIV
><DIV
CLASS="NAVFOOTER"
><HR
ALIGN="LEFT"
WIDTH="100%"><TABLE
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
><A
HREF="checking-storage-space.html"
>Prev</A
></TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="index.html"
>Home</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
><A
HREF="redhat-processes.html"
>Next</A
></TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
>Checking Storage Space</TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="various-and-sundry.html"
>Up</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
>Starting and Stopping Processes</TD
></TR
></TABLE
></DIV
></BODY
></HTML
>