Newbie School: how to add a service in a Linux operating system

Source: Internet
Author: User
First, copy the following template for backup. The following is an explanation! Binsh indicates the shell type called by the script. chkconfig: 23458005 indicates the operation of the service.

Copy the following template for backup.

#! /Bin/sh indicates the shell type called by the script.

# Chkconfig: 2345 80 05 2345 indicates the service running level. 80 indicates that the 80th service must be started when the system starts (the service number can be repeated ). 05 indicates the service number to be stopped when the system is disabled.

# Descr restart ption: you can add the service here, but you must have

Case $1 in here is a selection statement. $1 is a variable used to refer to the following start, stop, and so on.

Then you can write the command to start the service.

Stop) is the command executed when the service is stopped.

.

Save it as a service file, copy it to/etc/init. d/, start shell, and enter

Chkconfig -- add service

The service is successfully added.

Then you can use chkconfig -- list to view the custom service in the service list.

#! /Bin/sh # chkconfig: 2345 80 05 # descr restart ption: service case $1 instart); stop );;*);;

Esac

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.