tomcat启动脚本
author:headsen chen
date:2018-04-10 16:05:05
[root@arch tomcat-oss]# cat tomcat.sh
#!/bin/bash
export JAVA_HOME=/opt/jdk1.7.0_45
export JRE_HOME=${JAVA_HOME}/jre
export CATALINA_HOME=/opt/tomcat-oss
export CLASSPATH=.:$JAVA_HOME/lib/tools.jar:$JAVA_HOME/lib/dt.jar:$CLASSPATH:${CATALINA_HOME}/lib
#export PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin:/usr/local/sbin:${JAVA_HOME}/bin:${CATALINA_HOME}/bin
export PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin:/usr/local/sbin:${JAVA_HOME}/bin:${CATALINA_HOME}/bin:/opt/apr/bin:/opt/apr-util/bin:/opt/apr-iconv/bin
export LD_LIBRARY_PATH=/lib:/lib64:/usr/lib:/usr/lib64:/usr/local/lib:/usr/local/lib64:/opt/tnative/lib:/opt/apr/lib:/opt/apr-util/lib:/opt/apr-iconv/lib
Tomcat_User=tomcat
function start_server0 ()
{
su `echo $Tomcat_User` $CATALINA_HOME/bin/catalina.sh start
}
function stop_server0 ()
{
ID=`ps -ef | grep java | grep tomcat-oss|awk '{print $2}'`
if [ -n "$ID" ]; then
su `echo $Tomcat_User` $CATALINA_HOME/bin/catalina.sh stop
else
printf "no instance is running \n"
fi
for id in $ID
do
kill -9 $id
echo "kill -9 $id"
done
}
if [ "$1" = "start" ]; then
start_server0
elif [ "$1" = "stop" ]; then
stop_server0
else
printf " server the options {start|stop}\n"