How to set the service to start from Linux

Source: Internet
Author: User
Tags reset stop script linux

To avoid the hassle of manually booting a service every time the system starts up, we need to set the service to start from boot.

1, first of all, check whether there is a required service under the/ETC/INIT.D, and then add:

# ls-l/ETC/INIT.D/HTTPD

-rwxr-xr-x 1 root root 3200 Nov 2008/etc/init.d/httpd

2, add the service from the startup list:

# chkconfig--add httpd

3, check the status of the service in the Linux mode is On/off, on means that automatically start in this mode, off vice versa:

# chkconfig--list httpd

httpd 0:off 1:off 2:off 3:off 4:off 5:off 6:off

Where the pattern number meaning:

0 shutdown (do not set the default run level to 0)

1 Single user mode

2 text multiuser mode with no NFS

3 Full multiuser mode

4 Not defined

5 graphical interface

6 reboot (do not set the default run level to 6)

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.

4, change the status of the mode:

# chkconfig--level 345 httpd on

On and off each service is started and stopped, reset refers to resetting the service's startup information, regardless of the problematic initialization script. On and off switches, the system defaults to run-level 3,4,5 only, but reset can be valid for all run levels.

5, check the modified status:

# chkconfig--list httpd

httpd 0:off 1:off 2:off 3:on 4:on 5:on 6:off

Report:

Linux command: Chkconfig

Function Description: Check, set up the various services of the system; The Chkconfig command is used primarily to update (start or stop) and to query run-level information for system services. Remember that Chkconfig does not automatically disable or activate a service immediately, it simply changes the symbolic connection.

Syntax: chkconfig [--add][--del][--list][system service] or Chkconfig [--level< registration code >][system service][on/off/reset]

Supplemental Note: This is a program developed by the Redhat company in accordance with the GPL rules, which can query the system services that the operating system performs in each execution level, including all kinds of resident services.

Parameters:

--add adds the system services that are developed, allows the chkconfig directives to manage it, and adds relevant data to the system-initiated narrative file.

--del deletes the system services that are established and is no longer managed by the Chkconfig command, and deletes the relevant data in the system-initiated narration file.

--level< Level code > Set up read system services to open or close in which level of execution.

This article from the "Small Hebebe Technical Space" blog, please be sure to keep this source http://babyhe.blog.51cto.com/1104064/785728

See more highlights of this column: http://www.bianceng.cn/OS/Linux/

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.