publish_tomcat.sh

#!/bin/bash
# Description: 
#    We should enter into tomcat home directory and sz a war, then we can execute this script.
#    Use "mvn clean package -Dmaven.test.skip=true -Dskiptests=true -P env-prod" command to get the war.java

# allow job control
set -mweb

application_dir="server-name"tomcat

# current directory that is tomcat home directory
cur_dir=$(pwd)
echo $cur_dirbash

#
cd  $cur_dir
mkdir -p webapps/$application_dirapp

# set backup dir
backup="backup"webapp

# set the war backup
cur_time=$(date +%F-%H-%M-%S) maven

# war backup
#/bin/mv -f *.war $backup/$(cur_time).warthis

# stop the tomcat server
ps aux | grep java | grep $cur_dir | awk  '{print $2}' | xargs kill -9server

# webapps backup
mv  webapps/$application_dir/ ./$backup/webapp.`date +%F-%H-%M-%S`ip

#delete work directory
/bin/rm -rf $cur_dir/work/

# unzip 
unzip -d $cur_dir/webapps/$application_dir *.war

#start the tomcat server
$cur_dir/bin/catalina.sh start

# #tail -f $cur_dir/logs/catalina.out tail -f $cur_dir/logs/catalina.out.`date +%Y-%m-%d`

相關文章
相關標籤/搜索
本站公眾號
   歡迎關注本站公眾號,獲取更多信息