⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 431-434.html

📁 linux-unix130.linux.and.unix.ebooks130 linux and unix ebookslinuxLearning Linux - Collection of 12 E
💻 HTML
字号:
<HTML>

<HEAD>

<TITLE>Using Linux:Managing Scheduling Services</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=0789716232//-->

<!--TITLE=Using Linux//-->

<!--AUTHOR=William Ball//-->

<!--PUBLISHER=Macmillan Computer Publishing//-->

<!--IMPRINT=Que//-->

<!--CHAPTER=26//-->

<!--PAGES=431-434//-->

<!--UNASSIGNED1//-->

<!--UNASSIGNED2//-->



<CENTER>

<TABLE BORDER>

<TR>

<TD><A HREF="429-431.html">Previous</A></TD>

<TD><A HREF="../ewtoc.html">Table of Contents</A></TD>

<TD><A HREF="434-437.html">Next</A></TD>

</TR>

</TABLE>

</CENTER>

<P><BR></P>

<P><TT><I>action</I></TT> and <TT><I>process</I></TT> are easily confused. The action is what <TT>init</TT> does, not what the process does. There are 14 possible actions, as illustrated in Table 26.2.</P>

<TABLE WIDTH="100%"><CAPTION ALIGN=LEFT><B>Table 26.2</B> Possible actions <I>init</I> can take

<TR>

<TH COLSPAN="2"><HR>

<TR>

<TH WIDTH="20%" ALIGN="LEFT">Action

<TH WIDTH="80%" ALIGN="LEFT">Description

<TR>

<TD><TT>respawn</TT>

<TD><TT>init</TT> restarts the process whenever the process terminates.

<TR>

<TD VALIGN="TOP"><TT>wait</TT>

<TD><TT>init</TT> starts this process, and waits for it to complete before continuing to the next process.

<TR>

<TD VALIGN="TOP"><TT>once</TT>

<TD><TT>init</TT> starts this process and moves on. If/when this process terminates, it is not restarted.

<TR>

<TD><TT>boot</TT>

<TD>This process runs during system boot. The <TT><I>runlevel</I></TT> field is ignored.

<TR>

<TD VALIGN="TOP"><TT>bootwait</TT>

<TD><TT>init</TT> starts this process at system boot, and waits for it to complete before continuing. The <TT><I>runlevel</I></TT> field is ignored.

<TR>

<TD><TT>off</TT>

<TD>This does not run.

<TR>

<TD VALIGN="TOP"><TT>ondemand</TT>

<TD>This process is run whenever the specified <TT>ondemand</TT> run level is called. No actual run level change occurs. <TT>ondemand</TT> run levels are a, b, and c.

<TR>

<TD VALIGN="TOP"><TT>initdefault</TT>

<TD>This entry specifies the run level that should be entered after system boot. If none exists, <TT>init</TT> asks for a run level on the console. The <TT><I>process</I></TT> field is ignored. The default value is 3.

<TR>

<TD VALIGN="TOP"><TT>sysinit</TT>

<TD>This process is executed during system boot, and before any <TT>boot</TT> or <TT>bootwait</TT> entries. The <TT><I>runlevel</I></TT> field is ignored.

<TR>

<TD VALIGN="TOP"><TT>powerwait</TT>

<TD>This process is executed when <TT>init</TT> receives the <TT>SIGPWR</TT> signal, indicating that there is something wrong with power. <TT>init</TT> waits for the process to finish before continuing.

<TR>

<TD VALIGN="TOP"><TT>powerfail</TT>

<TD>This process is executed when <TT>init</TT> receives the <TT>SIGPWR</TT> signal, indicating that there is something wrong with power. <TT>init</TT> does not wait for the process to finish before continuing.

<TR>

<TD VALIGN="TOP"><TT>powerokwait</TT>

<TD><TT>init</TT> executes this command when it receives the <TT>SIGPWR</TT> signal, provided that there is a file called <TT>/etc/powerstatus</TT> containing the word OK. This indicates that the power has come back on again.

<TR>

<TD VALIGN="TOP"><TT>ctrlaltdel</TT>

<TD><TT>init</TT> executes this process when it receives the <TT>SIGINT</TT> signal. This means that someone on the system console has pressed the Ctrl&#43;Alt&#43;Del key combination. Typically, this is either a shutdown command or a boot to single-user mode.

<TR>

<TD VALIGN="TOP"><TT>kbrequest</TT>

<TD>This is one of the newer actions. When <TT>init</TT> receives a signal from the keyboard handler that a special key combination was pressed on the console keyboard, then this command is executed. See documentation found in the <TT>kbd-x.xx</TT> package for more information.

<TR>

<TD COLSPAN="2"><HR>

</TABLE>

<P>Listing 26.1 shows an example <TT>inittab</TT> file from a machine running Red Hat Linux 5.0.</P>

<P><B>Listing 26.1</B> A sample <I>inittab</I> file from a system running Red Hat Linux 5.0</P>

<!-- CODE //-->

<PRE>

 #

# inittab   This file describes how the INIT process should set up

#            the system in a certain run-level.

#

# Author:   Miquel van  Smoorenburg,&lt;miquels&#64;drinkel.nl.mugnet.org&gt;

#            Modified for RHS Linux by Marc Ewing and Donnie Barnes

#



# Default run level. The run levels used by RHS are:

#  0 - halt (Do NOT set initdefault to this)

#  1 - Single user mode

#  2 - Multiuser, without NFS (The same as 3, if you do not have

       networking)

#  3 - Full multiuser mode

#  4 - unused

#  5 - X11

#  6 - reboot (Do NOT set initdefault to this)

#

id:3:initdefault:



# System initialization.

si::sysinit:/etc/rc.d/rc.sysinit



l0:0:wait:/etc/rc.d/rc 0

l1:1:wait:/etc/rc.d/rc 1

l2:2:wait:/etc/rc.d/rc 2

l3:3:wait:/etc/rc.d/rc 3

l4:4:wait:/etc/rc.d/rc 4

l5:5:wait:/etc/rc.d/rc 5

l6:6:wait:/etc/rc.d/rc 6



# Things to run in every run level.

ud::once:/sbin/update



# Trap CTRL-ALT-DELETE

ca::ctrlaltdel:/sbin/shutdown -t3 -r now



# When our UPS tells us power has failed, assume we have a few minutes

# of power left.  Schedule a shutdown for 2 minutes from now.

# This does, of course, assume you have powerd installed and your

# UPS connected and working correctly.

pf::powerfail:/sbin/shutdown -f -h &#43;2 &#147;Power Failure; System Shutting

    Down&#148;

#  If power was restored before the shutdown kicked in, cancel it.

pr:12345:powerokwait:/sbin/shutdown -c &#147;Power Restored; Shutdown 

    Cancelled&#148;



# Run gettys in standard run levels

1:12345:respawn:/sbin/mingetty tty1

2:2345:respawn:/sbin/mingetty tty2

3:2345:respawn:/sbin/mingetty tty3

4:2345:respawn:/sbin/mingetty tty4

5:2345:respawn:/sbin/mingetty tty5

6:2345:respawn:/sbin/mingetty tty6



# Run xdm in run level 5

x:5:respawn:/usr/bin/X11/xdm -nodaemon

</PRE>

<!-- END CODE //-->

<P>A number of the lines should now be familiar. It is good to point out that the <TT>id</TT> of each of these entries corresponds with the entry itself (for example, <TT>pf</TT> = power fail). This is a good habit to get into. Also, from the <TT>lilo</TT> line, you can specify a level by entering the following (in which <TT>#</TT> is the runtime level you want to use):</P>

<!-- CODE SNIP //-->

<PRE>

<B>linux #</B>

</PRE>

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

<P><BR></P>

<CENTER>

<TABLE BORDER>

<TR>

<TD><A HREF="429-431.html">Previous</A></TD>

<TD><A HREF="../ewtoc.html">Table of Contents</A></TD>

<TD><A HREF="434-437.html">Next</A></TD>

</TR>

</TABLE>

</CENTER>





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

<!-- begin footer information -->





</body></html>

⌨️ 快捷键说明

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