The chkconfig command is used to update (start or stop) and query the running level information of the system service. Remember that chkconfig is not automatically disabled or activated immediately.
The chkconfig command is used to update (start or stop) and query the running level information of the system service. Remember that chkconfig does not automatically disable or activate a service immediately, but simply changes the symbolic connection.
Syntax:
Chkconfig [-- add] [-- del] [-- list] [system service] or chkconfig [-- level <等级代号> ] [System service] [on/off/reset]
The usage of chkconfig is displayed when no parameter is available. If the service name is added, check whether the service is started at the current running level. If yes, true is returned; otherwise, false is returned. If on, off, or reset is specified after the service name, chkconfi changes the startup information of the specified service. On and off indicate that the service is started and stopped, and reset indicates that the service startup information is reset, no matter what is specified by the problematic initialization script. On and off switches. by default, the system is only valid for 3, 4, and 5 running levels, but the reset can be valid for all running levels.
Parameter usage:
-- Add adds the specified system service, enables the chkconfig command to manage it, and adds relevant data in the system startup description file.
-- Del: deletes the specified system service. it is no longer managed by the chkconfig command, and relevant data is also deleted in the description file started by the system.
-- Level <等级代号> Specify the execution level of the Read system service.
Level 0: Shutdown
Level 1: Single user mode
Level 2: Multi-user command line mode without network connection
Level 3: Multi-user command line mode with network connection
Level 4: Unavailable
Level 5: Multi-user mode with graphic interface
Level 6: Restart
It should be noted that the level option can specify the running level to be viewed, not necessarily the current running level. For each running level, only one startup script or stop script is allowed. When you switch to the running level, init does not restart the started service or stop the stopped service again.
Chkconfig -- list [name]: displays the running status information (on or off) of all running-level system services ). If the name is specified, only the status of the specified service at different running levels is displayed.
Chkconfig -- add name: add a new service. Chkconfig ensures that each running level has a startup (S) or kill (K) entry. If the init script is missing, it is automatically created from the default init script.
Chkconfig -- del name: delete the service and delete the connection from/etc/rc [0-6]. d.
Chkconfig [-- level levels] name: Sets whether a service is started, stopped, or reset at the specified running level.
Run-level files:
Each service managed by chkconfig needs to add two or more lines of comments to the script in the corresponding init. d. The first line tells chkconfig the default startup running level and the priority of start and stop. If a service is not started at any running level by default, use-to replace the running level. The second line describes the service. you can use the \ cross-line comment.
For example, random. init contains three rows:
# Chkconfig: 2345 20 80
# Description: Saves and restores system entropy pool \
# Higher quality random number generation.
Example:
Chkconfig -- list # list all System Services
Chkconfig -- add httpd # add httpd service
Chkconfig -- del httpd # Delete the httpd service
Chkconfig -- level httpd 2345 on # sets httpd to on when the running level is 2, 3, 4, or 5.
Chkconfig -- list # list all system startup statuses
Chkconfig -- list mysqld # list mysqld service settings
Chkconfig -- level 35 mysqld on # set mysqld to run at level 3 and 5. -- level 35 indicates that the operation is only executed at level 3 and 5, on indicates that the operation is started, and off indicates that the operation is disabled.
Chkconfig mysqld on # set mysqld to on at each level. "each level" includes 2, 3, 4, and 5 levels.
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 chkconfig tool service list. in this case, the service will be assigned a K/S entry in/etc/rc. d/rcN. d;
3. chkconfig -- level 35 mysqld on
Modify the default service start level.