在/etc/init.d/目录下编写脚本test_server_d,给755权限,内容如下:
#!/bin/bash # chkconfig: 2345 81 90 # description: myservice .... RETVAL=0 test_server="/usr/local/test_server/bin/test_linux" start() { echo "starting..." cd /usr/local/test_server/bin $test_server return $RETVAL } stop() { echo "Stopping..." killall -9 test_server return $RETVAL } case "$1" in start) start ;; stop) stop ;; restart) sh $0 stop sh $0 start ;; *) echo "command error!" echo $"Usage: $0 {start|stop|restart}" exit 1 ;; esac exit $RETVAL
然后调用
chkconfig --add test_server,重启即可
如果删除开启启动,执行chkconfig --del