The bash script is registered as a service and automatically started upon startup. details about the chkconfig command

Source: Internet
Author: User
Tags stop script
The bash script is registered as a service and automatically started upon startup. 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. Use the bash script to register as a service and start automatically upon startup. the chkconfig command is used to update (start or stop) and query the running level 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] chkconfig displays usage when no parameters are 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 needs to be noted that, the level option specifies 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 file: 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 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 lines: # chkconfig: 2345 20 80 # description: Saves and restores system entropy pool for \ # higher quality random number generation. example: chkconfig -- list # list all system services chkconfig -- add httpd # add httpd service chkconfig -- del httpd # delete httpd service chkconfig -- level httpd 2345 on # set httpd to 2 at runtime level, 3, 4, and 5 are all on (enabled) status chkconfig -- list # list all system service startup conditions chkconfig -- list mysqld # list mysqld service settings chkconfig -- Level 35 mysqld on # set mysqld in level 3 and 5 to start the service, -- level 35 indicates that the operation is only executed in level 3 and 5, and on indicates that the operation is started, off indicates disabling chkconfig mysqld on # set mysqld to on at each level. "each level" includes 2, 3, 4, and 5. how to add a service: 1. the service script must be stored in/etc/ini. d/directory; 2. chkconfig -- add servicename add this service to the chkconfig tool service list. The service will be added to/etc/rc. d/rcN. d is assigned to the K/S entry; 3. chkconfig -- level 35 mysqld on modify the default service startup level.
Related Article

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.