vim /etc/init.d/xiao2d
---------------------------------------------
#!/bin/bash
# chkconfig: 2345 99 99
# description: initialization xiao2 deamon
RETVAL=0
XIAO2D_BIN=/usr/bin/xiao2d
prog=xiao2d
echo "start xiao2 deamon" >> /root/xiao2.log
case "$1" in
start)
echo $"Starting $prog"
$XIAO2D_BIN
;;
stop)
echo $"Shutting down $prog"
ps -ef | grep -v "grep" | grep $XIAO2D_BIN | awk '{print $2}' | xargs -r kill -s 9
;;
restart)
$0 stop
$0 start
;;
status)
ps -ef | grep -v "grep" |grep $XIAO2D_BIN
;;
*)
echo $"Usage: $0 {start|stop|restart|status}"
RETVAL=1
esac
exit $RETVAL
---------------------------------------------
chkconfig --add xiao2d
若希望改变启动顺序:
1、更改# chkconfig: 2345 99 99中 99的值,前面为开机顺序,后面为关机顺序,小于100
2、chkconfig --del xiao2d
3、chkconfig --add xiao2d
4、chkconfig xiao2d on