chkconfig --add mytest
or
chkconfig --levels 2345 mytest on
or
chkconfig --levels 2345 mytest off
RET=0
start_proc() {
xxxx
RET=$?
return $RET
}
stop_proc() {
xxxx
RET=$?
return $RET
}
restart_proc() {
xxxx
RET=$?
return $RET
}
case "$1" in
start)
do start_proc;
;;
stop)
do stop_proc;
;;
restart)
do restart_proc;
;;
*)
echo "Please usage: $0 {start|stop|restart}"
exit 1
;;
esac
exit $RET
说明:
#!/bin/bash -e 表示脚本执行遇到第一个错误时就中止运行
service mytest status
or
chkconfig --levels 2345 mytest on
or
chkconfig --levels 2345 mytest off
vim mytest
#!/bin/bash -eRET=0
start_proc() {
xxxx
RET=$?
return $RET
}
stop_proc() {
xxxx
RET=$?
return $RET
}
restart_proc() {
xxxx
RET=$?
return $RET
}
case "$1" in
start)
do start_proc;
;;
stop)
do stop_proc;
;;
restart)
do restart_proc;
;;
*)
echo "Please usage: $0 {start|stop|restart}"
exit 1
;;
esac
exit $RET
说明:
#!/bin/bash -e 表示脚本执行遇到第一个错误时就中止运行
service mytest status
service mytest start|stop|restart