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