#!/bin/bash
#
# Let's call it sample.sh
# For example, define the current Run Level:
runl=`/sbin/runlevel | awk '{ print $2 }'`
nowd=`date`
start() {
# start function
echo "$nowd -- start sample script at Run Level $runl" | tee -a /var/log/sample.log
# ....
}
stop() {
# stop function
echo "$nowd -- stop sample script at Run Level $runl" | tee -a /var/log/sample.log
# ....
}
status() {
# status function
echo "status sample script at Run Level $runl"
# .....
}
restart(){
stop
start
}
case "$1" in
start)
start
;;
stop)
stop
;;
status)
status
;;
restart)
restart
;;
*)
echo $"Usage: $0 {start|stop|status|restart}"
exit 1
esac
|