Linux under chkconfig command detailed

Source: Internet
Author: User
Tags reset stop script

  The chkconfig command is used primarily to update (start or stop) and to query run-level information for system services. Keep in mind that Chkconfig is not immediately automatically banned or activated by a service, it simply changes the symbolic connection-

Use syntax:

chkconfig[--add][--del][--list][system service] or chkconfig[--level< grade code >][system service][on/off/reset]

Chkconfig Displays the usage when no parameters are running. If you add a service name, check to see if the service is starting at the current run level. Returns true if it is, or false. If On,off or reset is specified after the service name, CHKCONFI changes the startup information for the specified service. On and off means that the service is started and stopped, and reset refers to resetting the service's startup information, regardless of what the initialization script for the problem specifies. On and off switches, the system defaults to run-level 3,4,5 only, but reset can be valid for all run levels.

Parameter usage:

--add adds the specified system service, allows the chkconfig instruction to manage it, and adds the relevant data to the system-initiated narrative file.

--del deletes the specified system service, is no longer managed by the Chkconfig command, and deletes the relevant data in the system-initiated narration file.

--level< Level Code > Specify the system service to be opened or closed in which execution level.

Level 0 means: the shutdown

Level 1: 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 connections

Level 4 indicates: Not available

Level 5 means: Multi-user mode with graphical interface

Level 6 indicates: reboot

It is necessary to note that the level option can specify the run levels to view, not necessarily the current run level. For each run level, there can be only one startup script or stop script. When the run level is switched, Init does not restart the service that has started, nor does it stop the service that has stopped.

Chkconfig--list[name]: Displays the running status information (on or off) for all run-level system services. If name is specified, only the state of the specified service at a different run level is displayed.

Chkconfig--addname: Add a new service. Chkconfig ensure that each run level has a start (S) or Kill (K) entry. If it is missing, it is automatically created from the default init script.

Chkconfig--delname: Deletes the service and deletes the associated symbol connection from/ETC/RC[0-6].D.

Chkconfig[--levellevels]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 be annotated with two or more lines of script under the corresponding INIT.D. The first line tells Chkconfig the run level of the default boot and the priority of start and stop. If a service does not start at any run level by default, then use-instead of run level. The second line describes the service, and you can use a cross row annotation.

For example, Random.init contains three lines:

#chkconfig: 23452080

#description: Savesandrestoressystementropypoolfor

#higherqualityrandomnumbergeneration.

Use Example:

chkconfig--list# List all system services

chkconfig--addhttpd# Increase httpd Service

chkconfig--delhttpd# Delete httpd Service

The chkconfig--levelhttpd2345on# setting httpd is on (open) at Run Level 2, 3, 4, 5

chkconfig--list# Lists all service startup scenarios for the system

chkconfig--listmysqld# List mysqld Service settings

chkconfig--level35mysqldon# set mysqld at level 3 and 5 for boot run service,--LEVEL35 indicates operation only at level 3 and 5, on is started, off means off

chkconfigmysqldon# set MYSQLD on each level, "each level" includes 2, 3, 4, 5 grade

How to add a service:

1. Service scripts must be stored in the/etc/ini.d/directory;

2.chkconfig--addservicename

Add this service to the Chkconfig tool Services list, at which point the service is given a k/s entry in the/ETC/RC.D/RCN.D;

3.chkconfig--level35mysqldon

Modify the default boot level for the service.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.