How to customize service scripts and how to create standard rpm service scripts

Source: Internet
Author: User

How to customize service scripts and how to create standard rpm service scripts
Custom Service script:

#!/bin/bash#myscript#chkconfig: 2345 90 20#description:  Starts, stops and saves iptables firewallcase $1 in    start)       echo "start my script!!"       sleep 1       ;;    restart)       echo "restart my script!!"       sleep 1       ;;    stop)       echo "stop my script!!"       sleep 1       ;;    *)        echo "please input start|restart|stop"       sleep 1       ;;  esac
In this case, you cannot use chkconfig for management. You need to add the Code # chkconfig: 2345 90 20. At the 2345 level, the sequence of startup execution is 90, and the sequence of shutdown execution is 20 # description: Starts, after adding stops and saves iptables firewall, run: chkconfig myscript on chkconfig -- list myscript.

Transform the service script into a standard rpm script:
# Chkconfig: 2345 90 20
In the 2345 level, the sequence of startup and shutdown operations is 90, and the sequence of shutdown operations is 20.
# Description: Starts, stops and saves iptables firewall

Use service to enable and disable the Custom Script:
Service myscript start | stop | restart

Use chkconfig to set the custom script to boot:
Chkconfig myscript on
Chkconfig myscript off

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.