klsd必须放到/etc/rc.d/init.d
#!/bin/sh # # /etc/rc.d/init.d/klsd # This shell script takes care of starting and stopping # KingbaseES Listening Service(KLS). # # chkconfig: 35 85 15 # description: KingbaseES Listening Service. # processname: kls # pidfile: /var/run/kls.pid # Source function library. . /etc/rc.d/init.d/functions bin_dir="/usr/KingbaseES/bin" prog_user="kingbase" prog="kls" # Find the name of the script NAME=`basename $0` if [ ${NAME:0:1} = "S" -o ${NAME:0:1} = "K" ] then NAME=${NAME:3} fi test -x $bin_dir/$prog || exit 0 start() { pid=`pidof -s $bin_dir/$prog` if [ $pid ] then echo ___FCKpd___0quot;$prog already running." else echo -n "Starting ${NAME} service: " su -l $prog_user -s /bin/bash -c "cd $bin_dir && $bin_dir/$prog&" > /dev/null 2>&1 sleep 1 pid=`pidof -s $bin_dir/$prog` if [ $pid ] then echo_success touch /var/lock/subsys/${NAME} echo $pid > /var/run/${prog}.pid echo else echo_failure echo fi fi } stop() { echo -n ___FCKpd___0quot;Stopping ${NAME} service: " /bin/kill `cat /var/run/${prog}.pid 2> /dev/null ` > /dev/null 2>&1 ret=$? if [ $ret -eq 0 ] then echo_success else echo_failure fi echo rm -f /var/run/${prog}.pid rm -f /var/lock/subsys/${NAME} } restart() { stop while [ `pidof -s $bin_dir/$prog` ] do stop > /dev/null 2>&1 done start } condrestart() { [ -e /var/lock/subsys/${NAME} ] && restart } # See how we were called. case "$1" in start) start ;; stop) stop ;; status) status kls ;; restart) restart ;; condrestart) condrestart ;; *) echo ___FCKpd___0quot;Usage: $0 {start|stop|status|restart|condrestart}" exit 1 esac exit 0