跟上一篇添加zookeeper为服务基本类似
脚本如下:
#!/bin/bash CATALANA_HOME=/usr/local/tomcat8 export JAVA_HOME=/usr/local/java case $1 in start) echo "Starting Tomcat..." $CATALANA_HOME/bin/startup.sh ;; stop) echo "Stopping Tomcat..." $CATALANA_HOME/bin/shutdown.sh ;; restart) echo "Stopping Tomcat..." $CATALANA_HOME/bin/shutdown.sh sleep 2 echo echo "Starting Tomcat..." $CATALANA_HOME/bin/startup.sh ;; *) echo "Usage: tomcat {start|stop|restart}" ;; esac
注意:
若chkconfig -add 提示错误
添加
#chkconfig:2345 20 90
2、3、4、5 级别都启动,开启序号21 关闭断序号90