脚本存放目录 /etc/init.d/
#!/bin/bash # description: Tomcat7 Start Stop Restart # processname: tomcat7 # chkconfig: 234 20 80 CATALINA_HOME=/sdata/software/apache-tomcat-8.5.23 case $1 in start) sh $CATALINA_HOME/bin/startup.sh ;; stop) ps -e|grep java|awk '{print "kill -9 "$1}'|sh # sh $CATALINA_HOME/bin/shutdown.sh ;; restart) ps -e|grep java|awk '{print "kill -9 "$1}'|sh sleep 3 # sh $CATALINA_HOME/bin/shutdown.sh sh $CATALINA_HOME/bin/startup.sh ;; *) echo 'please use : tomcat {start | stop | restart}' ;; esac exit 0
/etc/init.d/tomcat restart 重启
/etc/init.d/tomcat start 启动
/etc/init.d/tomcat stop 停止