命令功能:updates and queries runlevel information for system services
更新或者查询系统服务的运行级别信息 -- 即:命令操作的必须是系统服务(查看/etc/init.d)
使用语法:
chkconfig [--add][--del][--list][系统服务] 或 chkconfig [--level <等级代号>][系统服务][on/off/reset]
查看系统服务的运行级别信息
chkconfig --list //所有系统服务运行级别信息
chkconfig --list servicename //指定服务信息。 servicename为服务名
chkconfig --add servicename
chkconfig --level 2345 servicename on //2345运行级别时,servicename开机运行
chkconfig --level 2345 servicename off
运行级文件:
每个被chkconfig管理的服务需要在对应的init.d下的脚本加上两行或者更多行的注释。第一行告诉chkconfig缺省启动的运行级以及启动和停止的优先级。如果某服务缺省不在任何运行级启动,那么使用 - 代替运行级。第二行对服务进行描述,可以用\ 跨行注释。
例如,/etc/init.d/jetty包含三行:
# chkconfig: 2345 99 99
# description: jetty web server \
# additive description
另外,添加系统服务只需要将脚本添加到/etc/init.d目录下即可,该脚本应能处理start|stop|restart等参数,并作相应处理
检查系统运行级别:runlevel
系统默认运行级别配置文件:/etc/inittab