Detailed chkconfig command (centos 7)

chkconfig command is mainly used to update operational level information (start or stop) and query system services. Remember chkconfig not immediately activate automatically disabled or a service, it simply changes the symbolic link.

Using the syntax:

chkconfig [--add] [- del] [- list] [System Services] or chkconfig [--level <class code>] [Service System] [on / off / reset]

  chkconfig run when no parameters, display usage. If you add the service name, then check whether the service starts running in the current level. If so, returns true, otherwise false. If you specify a service name after the on, off or reset, it will change the start chkconfi information specified service. on and off, respectively, refer to the service is started and stopped, reset means that resets the startup information services, regardless of the initial question of what the script specified. on and off switch, only the default class 3,4,5 effective operation, but the reset may be active in all stages.

Parameters Usage:

-Add increase the specified system services to chkconfig command to manage it, and at the same time increasing the data in the system startup file description.
-Del delete the specified system service is no longer managed by chkconfig command, and delete data in the system startup file description.
-Level <level code> Specifies the reading system to be turned on or off services in which Bi execution levels.
Level 0 represents: represents off
Level 1 represents: single-user mode
Level 2 represents: no network connection multi-user command line
Level 3 means: a multi-user command line network connection
Level 4 represents: N
represents Level 5: belt multi-user mode GUI
grade 6, said: restart

  It should be noted, level option to specify the level you want to view the run and not necessarily the current operating level. For each run level, only one startup script or a stop script. When switching run level, init does not restart the service has been launched, it will not have to stop to stop the service again.

chkconfig -list [name]: displaying the operation state information of all system services run level (on or off). If the name is specified, then displays only the status of the specified services at different run levels.
chkconfig -add name: to add a new service. chkconfig to ensure that each class has a running start (S) or killed (K) entrance. If anything is missing, it will automatically establish the default init scripts.
chkconfig -del name: delete services, and the related symbolic link from /etc/rc[0-6].d.
chkconfig [--level levels] name: Set a service to run at a specified level is to be started, stopped or reset. 

Run-level file:

Each script is required under the corresponding init.d plus two lines or more lines of comments chkconfig management services. The first line tells chkconfig default startup run levels and start and stop priority. If a service is not in default of any level to start running, use - instead of run level. The second line of the service description, you can use \ interbank comment.
For example, random.init comprising three lines:

# chkconfig: 2345 20 80
# description: Saves and restores system entropy pool for \
# higher quality random number generation.

Use examples:

chkconfig -list # list all system services


chkconfig -add httpd # service httpd increase
chkconfig -del httpd # delete httpd service
chkconfig -level httpd 2345 on # Set httpd running level case 2,3,4,5 are on (open) state
chkconfig -list # list all system services startup situation
chkconfig -list mysqld # listed mysqld service settings circumstances
chkconfig -level 35 mysqld on # mysqld set at level 3 and 5 for the power to run the service, -level 35 indicates the operation only in grades 3 and 5 execution, on express start, off means closed
chkconfig mysqld on # mysqld in each level is set on, "each grade" rating include 2,3,4,5

 How to add a service :

1. Service script must be stored in /etc/ini.d/ directory;
2.chkconfig -add SERVICENAME
increase this service chkconfig tool in the list of services, in which case the service will be in /etc/rc.d/rcN.d imparting K / S of the inlet;
3.chkconfig mysqld ON -Level 35
changes to the default level of service is started.

Guess you like

Origin www.cnblogs.com/yyxianren/p/12395589.html