exec command
target/*.war
/opt/tomcat-8080(无用)
/opt/tomcatDeploy.sh rosefinch-web 8080 /opt/tomcat-8080
#!/bin/bash #默认变量值 TOMCAT_HOME="$3" TOMCAT_PORT="$2" PROJECT="$1" source /etc/profile #参数检验./deploy.sh <projectname> [tomcat port] [tomcat home dir] if [ $# -lt 1 ]; then echo "you must use like this : ./deploy.sh <projectname> [tomcat port] [tomcat home dir]" exit fi if [ ! -n "$2" ]; then TOMCAT_PORT=$2 fi if [ ! -n "$3" ]; then TOMCAT_HOME="$3" fi #根据端口查找tomcatpid,可能有多个,循环中判断 tomcat_pid=`netstat -anp | grep $TOMCAT_PORT | awk '{printf $7}' | cut -d "/" -f 1` echo "current :" $tomcat_pid while [ -n "$tomcat_pid" ] do sleep 5 #进一步筛选 tomcat_pid=`ps -ef | grep $tomcat_pid |grep $TOMCAT_HOME | grep -v 'grep|tail|more|bash|less'| awk '{print $2}'` echo "scan tomcat pid :" $tomcat_pid if [ -n "$tomcat_pid" ]; then echo "kill tomcat :" $tomcat_pid kill -9 $tomcat_pid fi done #备份路径 #BAK_DIR=$HOME/war/bak/$PROJECT/`date +%Y%m%d` #mkdir -p "$BAK_DIR" #cp "$TOMCAT_HOME"/webapps/$PROJECT.war "$BAK_DIR"/"$PROJECT"_`date +%H%M%S`.war #publish project echo "scan no tomcat pid,$PROJECT publishing" rm -rf "$TOMCAT_HOME"/webapps/$PROJECT rm -rf "$TOMCAT_HOME"/webapps/$PROJECT.war cp /opt/war/$PROJECT.war "$TOMCAT_HOME"/webapps/$PROJECT.war #remove tmp rm -rf /opt/war/$PROJECT.war #start tomcat "$TOMCAT_HOME"/bin/startup.sh echo "tomcat is starting,please try to access $PROJECT conslone url"