470 472




Using Linux:Managing Daemons






-->















Previous
Table of Contents
Next




Editing and Creating Run Levels
init reads its configuration from the file /etc/inittab, which contains a number of pieces of information for init. It outlines what processes init should keep running (and restart if necessary) at each run level. Your logon prompts (called getty processes) are started and restarted by init. init reads the names of scripts to run when the system changes run level. This is probably the most confusing point about init and how the system starts: The scripts can (and usually do) also start processes. These are very different from the processes directly controlled by init, because they are not absolutely vital to the operation of the system (vital being defined here as being necessary to prevent the system from being completely inaccessible, as in not being able to log on at the console). The script that init calls, as well as exactly how it operates, is very much distribution dependent.
Red Hat Linux’s set of init scripts (so named because they are called by init, not because they are the initialization scripts) are kept in the /etc/rc.d and /etc/rc.d/init.d directories. The scripts in /etc/rc.d are there primarily for backward compatibility with other Linux distributions. The most noteworthy file is called rc.local, which is a shell script in which modifications specific to the particular Linux system would go on other systems. The standard installation’s rc.local script sets the /etc/issue file only to the version of Red Hat Linux that’s being used.
The more interesting directory is called the init.d directory. This directory holds a number of scripts that control the non-vital system services. If none of the services in this directory start, your system won’t do much, but hopefully init will have managed to start a logon prompt.
These directories are pretty vital to your system. In fact, I recommend that the entire /etc/ directory tree appear in every backup you do. Thank me later for reminding you.


Where should I start?
Most system services are not absolutely vital. If you need init to baby-sit the process to make sure it’s always running, it would be worthwhile for the daemon to be started from the inittab file. Thankfully, the vast majority of daemon programs do not require this sort of attention, and for ease of maintenance are best started from a script in /etc/rc.d/init.d and managed through the tksysv tool.
However, if the daemon is started from the inittab file and init needs to respawn (the term used for restarting a daemon process) the program too often, it disables the program for a while. You’ll see a message like the following in the kernel message file (/var/log/messages):


init: process
respawning too fast.
disabled for 5 minutes




Editing inittab

Adding a process to the inittab file is pretty easy. Like many of the system files in Linux, this file is delimited by the colon (:) character. Each line has the following format:


[ID]:[Runlevels to be running at]:[Action]:[program name and
arguments]


Table 28.2 describes each field in the preceding code.

TABLE 28.2 Inittab file layout



Field Name
Description



ID
This is a short description of the line or event. For example, pressing Crtl+Alt+Delete causes init to look for the crtl-alt-del event in the inittab file. There are events for power failure as well, and along with the proper service process (also called daemon) this mechanism can provide for UPS monitoring (look up powerd in the man pages if you want to see how to do this). Services that are attached to terminal devices (virtual terminals or serial ports) use the name of the port after the letters tty as their ID (for example, ttyS1 becomes S1), since the tty prefix is implied.

Runlevels
This section contains the numbers for the run level on which the command should be executed (for example, 345).

Action
This tells init what action to take. A whole list of actions is documented in the inittab(5) man page, but the most commonly used actions are wait, respawn, and boot.

Program name and arguments
The last part of the inittab line contains the name of the program and the command-line arguments.





Remember the 3 B’s of system administration: back up, back up, and back up again
Make sure you have a backup copy of the inittab file before you start editing it.





Previous
Table of Contents
Next














Wyszukiwarka

Podobne podstrony:
470 472
Dz U 00 40 470 bezpieczeństwo i higiena pracy przy pracach spawalniczych
470 a
472 473
470 menu
470 11
472 W05 SKiTI modelTCPIP warstwa 3
469 472
07 (470)
470 Rozliczenie rozmów telefonicznych w księgach rachunkowych
470 04
DALI EVIDENCE 470
10 (470)

więcej podobnych podstron