±q 2002 ¦~°_¡AFreeBSD ¾ã¦X¤F NetBSD ªº rc.d
¾÷¨î¨Ó§@¬°¨t²ÎªA°È±Ò°Ê¾÷¨î¡C ¥i¥H¨ì /etc/rc.d
¥Ø¿ý¤U¥h¬Ý¡A«Ü¦hÀɮ׳£¬O°ò¥»ªA°È¡A¥i¥H¥Î start
, stop
¤Î restart
§@¬°¨Ï¥Î®Éªº¿ï¶µ¡C
Á|Ó¨Ò¤l¡A¥i¥H¥Î¤U¦C«ü¥O¨Ó«·s±Ò°Ê sshd(8)¡G
# /etc/rc.d/sshd restart
¨ä¥LªA°È¤]¬OÃþ¦ü§@ªk¡C·íµM¡A ªA°È³q±`¥un¦b rc.conf(5) ¤º¦³«ü©wªº¸Ü¡A³£·|¦b¶}¾÷®É´N¦Û°Ê±Ò°Ê¡CÁ|¨Ò¨Ó»¡¡AYn¶}¾÷®É±Ò°Ê NAT(Network Address Translation) daemon ªº¸Ü¡A¥un¦b /etc/rc.conf ¤º¥[¤W¤U¦C³o¦æ§Y¥i¡G
natd_enable="YES"
Y쥻¼gªº¬O natd_enable="NO"
¨º»ò¥un§â NO
§ï¬° YES
´N¦n¤F¡Crc scripts
·|¦b¤U¦¸«¶}¾÷®É¡A¦Û°Ê¸ü¤J¬ÛÃö(¦³¬Û¨Ì)ªºªA°È¡A¥H¤U§ÚÌ·|Á¿¨ì³o³¡¤À¡C
Since the rc.d system is primarily intended to start/stop
services at system startup/shutdown time, the standard start
,
stop
and restart
options will
only perform their action if the appropriate /etc/rc.conf
variables are set. For instance the above sshd restart command
will only work if sshd_enable
is set to YES
in /etc/rc.conf. To start
, stop
or restart
a service regardless of the settings in /etc/rc.conf, the commands should be prefixed with ¡§force¡¨. For
instance to restart sshd regardless of the current /etc/rc.conf setting, execute the following command:
# /etc/rc.d/sshd forcerestart
It is easy to check if a service is enabled in /etc/rc.conf
by running the appropriate rc.d script with the option
rcvar
. Thus, an administrator can check that sshd is in fact enabled in /etc/rc.conf by
running:
# /etc/rc.d/sshd rcvar # sshd $sshd_enable=YES
Note: The second line (# sshd) is the output from the sshd command, not a root console.
YnÀˬdªA°È¬O§_¦³¦b¹B§@¡A¥i¥H¥Î status
¿ï¶µ¨Ó¬d¸ß¡C¤ñ¦p¡GYn½T»{ sshd
¬O§_¯uªº¦³±Ò°Êªº¸Ü¡A¨º»ò¥´¡G
# /etc/rc.d/sshd status sshd is running as pid 433.
In some cases it is also possible to reload
a service.
This will attempt to send a signal to an individual service, forcing the service to
reload its configuration files. In most cases this means sending the service a SIGHUP signal. Support for this feature is not included for every
service.
The rc.d system is not only used for network services, it also contributes to most of the system initialization. For instance, consider the bgfsck file. When this script is executed, it will print out the following message:
Starting background file system checks in 60 seconds.
Therefore this file is used for background file system checks, which are done only during system initialization.
Many system services depend on other services to function properly. For example, NIS and other RPC-based services may fail to start until after the rpcbind (portmapper) service has started. To resolve this issue, information about dependencies and other meta-data is included in the comments at the top of each startup script. The rcorder(8) program is then used to parse these comments during system initialization to determine the order in which system services should be invoked to satisfy the dependencies. The following words may be included at the top of each startup file:
PROVIDE: Specifies the services this file provides.
REQUIRE: Lists services which are required for this service. This file will run after the specified services.
BEFORE: Lists services which depend on this service. This file will run before the specified services.
By using this method, an administrator can easily control system services without the hassle of ¡§runlevels¡¨ like some other UNIX® operating systems.
Additional information about the rc.d system can be found in the rc(8) and rc.subr(8) manual pages.
¥»¤å¤Î¨ä¥L¤å¥ó¡A¥i¥Ñ¦¹¤U¸ü¡Gftp://ftp.FreeBSD.org/pub/FreeBSD/doc/¡C
Y¦³ FreeBSD ¤è±ºÃ°Ý¡A½Ð¥ý¾\Ū FreeBSD ¬ÛÃö¤å¥ó¡A¦p¤£¯à¸Ñ¨Mªº¸Ü¡A¦A¬¢¸ß
<questions@FreeBSD.org>¡C
Ãö©ó¥»¤å¥óªº°ÝÃD¡A½Ð¬¢¸ß <doc@FreeBSD.org>¡C