http://t.zoukankan.com/yshyee-p-11866140.html
1:autodeploy_tomcat_app.sh
now=`date +%Y%m%d%H%M%S` tomcatPath=/home/test/apache-tomcat-8.5.34 backupPath=/home/test/apache-tomcat-8.5.34/backup war=$1 if [ -e "$war.war" ];then echo -e "war archive: $war.war" else echo -e "war archive '$war.war' not exists" exit -1 fi if [ ! -d "$backupPath" ]; then mkdir "$backupPath" fi echo "tomcat home: $tomcatPath" echo "backup path: $backupPath" echo 'try to stop tomcat...' pid=`ps aux|grep "java"|grep "$tomcatPath"|awk '{printf $2}'` if [ -n $pid ]; then echo "tomcat pid: $pid"; kill -9 $pid; fi echo 'stop tomcat finished...' echo 'backup old archive...' if [ -f "$tomcatPath/webapps/$war.war" ]; then mv -v "$tomcatPath/webapps/$war.war" "$backupPath/$1_$now.war"; fi rm -rf $tomcatPath/webapps/$war* echo "copy $war.war archive to webapps.." cp -v "$war.war" "$tomcatPath/webapps/" echo -e "33[32m" echo 'startup tomcat...' sh $tomcatPath/bin/startup.sh sleep 3 tail -f $tomcatPath/logs/catalina.out
2:将test.war上传至/home/test/apache-tomcat-8.5.34目录,然后执行以下脚本进行部署
sh autodeploy_tomcat_app.sh test
标签:脚本,Tomcat,tomcat,部署,webapps,pid,echo,tomcatPath,war From: https://www.cnblogs.com/zhoading/p/17026530.html