#!/bin/bash # description: Tomcat script # processname: # chkconfig: 234 20 80 # JAVA_HOME=/usr/java/jdk1.7.0_79 ### 自己的jdk路径 ### export JAVA_HOME PATH=$JAVA_HOME/bin:$PATH export PATH CATALINA_HOME=${tomcat_home} ### tomcat目录 ### TOMCAT_PORT=8888 #pid=`ps aux |grep /home/app/tomcat7|grep -v grep|awk ‘{print $2}‘` tomcat_pid=`/usr/sbin/lsof -n -P -t -i :$TOMCAT_PORT` # chown -R tomcat:tomcat ${tomcat_home} case $1 in start) /bin/su tomcat -s /bin/bash $CATALINA_HOME/bin/startup.sh if [ $? = 0 ];then echo "start OK" else echo "the tomcat is no starting" fi ;; stop) #/bin/su tomcat -s /bin/bash $CATALINA_HOME/bin/shutdown.sh kill -9 $tomcat_pid if [ $? = 0 ];then echo "stop OK" else echo "failure" fi ;; restart) #/bin/su tomcat -s /bin/bash $CATALINA_HOME/bin/shutdown.sh kill -9 $tomcat_pid if [ $? = 0 ];then echo "stop OK" else echo "failure" fi sleep 3 /bin/su tomcat -s /bin/bash $CATALINA_HOME/bin/startup.sh if [ $? = 0 ];then echo "start OK" else echo "the tomcat is no starting" fi ;; *) echo "Usage: tomcatd {start|stop|restart|status}" esac exit 0 # chmod +x /etc/init.d/tomcat.sh # chkconfig --add tomcat.sh //添加开机自启动 # chkconfig tomcat.sh on # chkconfig --list|grep 3:on //查看是否成功添加
时间: 2024-10-15 13:55:11