The Chkconfig command is primarily used to update (start or stop) and query run-level information for system services. Keep in mind that Chkconfig does not immediately automatically disable or activate a service, it simply changes the symbolic connection.
Use syntax:
chkconfig [--add][--del][--list][system service] or Chkconfig [--level < class Code >][system service][on/off/reset]
Chkconfig Displays the usage when no parameters are running. If the service name is added, check that the service is started at the current run level. If yes, returns TRUE, otherwise false is returned. If On,off or reset is specified after the service name, CHKCONFI will change the startup information for the specified service. On and off refers to the service being started and stopped, and reset refers to the boot information of the reset service, regardless of what is specified by the problematic initialization script. On and off switches, the system is only valid for run-level 3,4,5 by default, but reset can be valid for all run levels.
Parameter usage:
--add Adds the specified system service, allows the CHKCONFIG directive to manage it, and simultaneously adds relevant data to the system-initiated narrative file.
--del Deletes the specified system service, is no longer managed by the Chkconfig directive, and deletes the relevant data within the system-initiated narrative file.
--level< Level code > Specify which execution level the read system service is to turn on or off.
Level 0 means: Shutdown
level 1 means: single-user mode
Level 2 means: Multi-user command line mode with no network connection
Level 3 means: Multi-user command line mode with network connectivity
Level 4 means: Not available
level 5 means: Multi-user mode with graphical interface
Level 6 means: Restart
to be noted, the level option can specify the run levels to view and not necessarily the current run level. For each run level, there can be only one startup script or stop script. When you switch the run level, Init does not restart the service that is already started, nor does it stop the service that has stopped.
Chkconfig--list [name]: Displays the health status information (on or off) of all run-level system services. If name is specified, only the state of the specified service at a different run level is displayed.
Chkconfig--add Name: Add a new service. Chkconfig ensure that each run level has a start (S) or Kill (K) entry. If one is missing, it is automatically created from the default init script.
Chkconfig--del Name: Deletes the service and removes the associated symbolic connection from the/ETC/RC[0-6].D.
Chkconfig [--level Levels] Name: Sets whether a service is started, stopped, or reset at the specified run level.
Run-level files:
Each service managed by Chkconfig needs to add two or more lines of comments to the script under the corresponding INIT.D. The first line tells Chkconfig the run level of the default startup and the priority of start and stop. If a service does not start at any run level by default, use-instead of run-level. The second line describes the service, which you can annotate with \ cross-line.
For example, Random.init contains three rows:
# chkconfig:2345 20 80
# description:saves and restores system entropy pool for \
# higher quality random number generation.
Examples of Use:
Chkconfig--list #列出所有的系统服务
Chkconfig--add httpd #增加httpd服务
Chkconfig--del httpd #删除httpd服务
Chkconfig--level httpd 2345 on #设置httpd在运行级别为2, 3, 4, 5 in the case of On (open) state
Chkconfig--list #列出系统所有的服务启动情况
Chkconfig--list mysqld #列出mysqld服务设置情况
Chkconfig--level mysqld on #设定mysqld在等级3和5为开机运行服务,--level 35 means that the operation is performed only on levels 3 and 5, on means start, off means off
Chkconfig mysqld on #设定mysqld在各等级为on, "each level" includes 2, 3, 4, 5 ratings
How to add a service:
1. The service script must be stored in the/etc/ini.d/directory;
2.chkconfig--add ServiceName
Add this service to the list of Chkconfig tool services, at which point the service is given the k/s entry in/ETC/RC.D/RCN.D;
3.chkconfig--level mysqld on
Modifies the default startup level of the service.
Chkconfig commands under Linux--(start or stop) and query the system service for run-level information