#!/bin/bash#myscript#chkconfig: 2345#description: Starts, stops and saves Iptables firewall Case $ inchStartEcho "Start my script!!"Sleep1;; RestartEcho "Restart my script!!"Sleep1;; StopEcho "Stop My script!!"Sleep1;; *)Echo "Please input start|restart|stop"Sleep1;;Esac
这样还不能使用chkconfig来管理,需要添加一下代码 #chkconfig: 2345 90 20 在2345级别下, 开机执行顺序是90, 关机执行顺序是20 #description: Starts, stops and saves iptables firewall 添加完后执行: chkconfig myscript on chkconfig --list myscript
-
Transform the service script into a standard RPM script:
#chkconfig: 2345 90 20
At level 2,345, the boot execution sequence is 90, and the shutdown execution sequence is 20.
#description: Starts, stops and saves Iptables firewall
-
To turn a custom script on and off via the service:
Service MyScript Start|stop|restart
-
Set up the custom script to boot by chkconfig:
Chkconfig MyScript on
Chkconfig MyScript off
How to customize service scripts and how to make standard RPM service scripts