语法为:
chkconfig --list [name] 用来列表服务
chkconfig --add name 用来添加服务
chkconfig --del name 用来删除服务
chkconfig [--level levels] name
on 和 off 分别指服务在改变运行级时的启动和停止。reset 指初始化服务信息。
对于 on 和 off 开关,系统默认只对运行级 3,4, 5有效,但是 reset 可以对所有运行级有效。
选项介绍:
--level levels
指定运行级,由数字 0 到 7 构成的字符串,如:
--level 35 表示指定运行级3 和5。
--add name
这个选项增加一项新的服务,chkconfig 确保每个运行级有一项
启动(S) 或者 杀死(K) 入口。如有缺少,则会从缺省的init
脚本自动建立。
--del name
用来删除服务,并把相关符号连接从 /etc/rc[0-6].d 删除。
--list name
列表,如果指定了name 那么只是显示指定的服务名,否则,列出
全部服务在不同运行级的状态。
运行级文件
每个被chkconfig 管理的服务需要在对应的/etc/rc.d/init.d 下的脚本加上两行或者更多行的注释。
第一行告诉 chkconfig 缺省启动的运行级以及启动和停止的优先级。如果某服务缺省不在任何运行级启动,那么使用 - 代替运行级。
第二行对服务进行描述,可以用\ 跨行注释。
例如,random.init 包含三行:
# chkconfig: 2345 20 80
# description: Saves and restores system entropy pool for \
# higher quality random number generation.
表明 random 脚本应该在运行级 2, 3, 4, 5 启动,启动优先权为20,停止优先权为 80。


karon_fedora 于 2007-05-02 22:35:17发表:
谢谢 楼主
下面是 man中关于chkconfig的描述,主要是chkconfig的工作原理,自己翻译的,不知道是否正确。
DESCRIPTION
chkconfig provides a simple command-line tool for maintaining
the /etc/rc[0-6].d directory hierarchy by relieving system administrators
of the task of directly manipulating the numerous symbolic links in
those directories.
chkconfig 提供了一个简单的命令行工具用于维护/etc/rc[0-6].d的路径层次,可以帮助系统管理员在这些路径中直接操作符号行
PS:简单的说就是用于维护/etc/rc[0.6].d的命令行,用不着这么麻烦
This implementation of chkconfig was inspired by the chkconfig command
present in the IRIX operating system. Rather than maintaining configu-
ration information outside of the /etc/rc[0-6].d hierarchy, however,
this version directly manages the symlinks in /etc/rc[0-6].d. This
leaves all of the configuration information regarding what services
init starts in a single location.
chkconfig 的执行是通过chkconfig命令激发的,此命令目前在irix操作系统中存在。甚至包括了维护/etc/rc[0-6].d层次之外的设置信息
但是本版本命令直接管理在/etc/rc[0-6].d中的符号行,这些设置信息主要是关于哪些服务在机器启动的时候就已经运行
PS:简单的说,就是chkconfig命令在irix操作系统中统统存在,甚至可以管理其他信息。
chkconfig has five distinct functions: adding new services for manage-
ment, removing services from management, listing the current startup
information for services, changing the startup information for ser-
vices, and checking the startup state of a particular service.
chkconfig有5个不同的函数:为管理器添加新服务,从管理器中移出服务,列出当前启动的服务信息,改变服务启动信息,检查特殊服务的启动状态
When chkconfig is run without any options, it displays usage informa-
tion. If only a service name is given, it checks to see if the service
is configured to be started in the current runlevel. If it is, chkcon-
fig returns true; otherwise it returns false. The --level option may be
used to have chkconfig query an alternative runlevel rather than the
current one.
当chkconfig没有任何参数运行的时候,它会显示用法信息,如果仅仅给了一个服务名称,他会去检查服务在目前的运行级别上是否被设定是可以运行的,如果可以运行的话,chkconfig返回true;不然的话返回false.--level选项被用来询问相对于目前运行等级,之外的一种运行登记
PS:返回true就是shell里什么都没有 ,--level是用来查询服务在其他等级是否可以运行的
If one of on, off, or reset is specified after the service name, chk-
config changes the startup information for the specified service. The
init script in question.
如果on off reset 跟在服务明后面,那么chkconfig会改变特定服务的启动信息。
PS:介绍on off reset 而已
By default, the on and off options affect only runlevels 2, 3, 4, and
5, while reset affects all of the runlevels. The --level option may be
used to specify which runlevels are affected.
默认的情况下,on和off选项只能在2.3.4,5级别下运行,而reset则在可以作用到所有的级别,--level选项可以确定那是一个级别能够起作用
Note that for every service, each runlevel has either a start script or
a stop script. When switching runlevels, init will not re-start an
already-started service, and will not re-stop a service that is not
running.
注意对所有的服务,每一个级别要么有一个启动脚本,要么有一个停止脚本,当改变运行级别时,启动不会重新启动一个已经运行的服务,也不会重新停止一个没有运行的服务
chkconfig also can manage xinetd scripts via the means of xinetd.d con-
figuration files. Note that only the on, off, and --list commands are
supported for xinetd.d services.
chkconfig同样可以管理超级守护进程经由xinetd.d的设置文件含义,注意这里仅仅可以用on 和off,并且--list命令也是支持xinetd.d服务的