tomcat发版脚本参考
#!/bin/bash
#包上传路径
dir_tmp="/mnt/ntfs/NImgShare1/Yprogram"
#包路径
dir_app="/home/tomcat/apache-tomcat-8.5.40"
#备份路径
backup="/home/tomcat/apache-tomcat-8.5.40/backup"
#进程名称
process="/home/tomcat/apache-tomcat-8.5.40/conf"
#包名称
war="image"
#时间标签
Date=$(date +%F)
echo "=======================Change version starting================================="
#杀进程
ps -ef |grep java|grep $process|awk '{print $2}'|xargs kill -9
echo "=============================kill tomcat====================================="
cd $dir_app/webapps
cp -rf $war.war $backup/$war.war.$Date
rm -rf $war*
cp -rf $dir_tmp/$war.war ./
sh $dir_app/bin/startup.sh
echo "===========================Change version End===================================="
验证URL脚本
#!/bin/bash
#地址链接
WEB_URL="http://10.142.114.76:8080/image/index.action"
#状态码
PRO_WEB=`curl -I -m 10 -o /dev/null -s -w '%{http_code}
' ${WEB_URL}`
#时间戳
DATE=`date +"%F %T"`
#红色
RED="E[31mE[01m"
#绿色
GREEN="E[5;32mE[01m"
#黄色
YELLOW="E[33mE[01m"
#紫红色
PURPLE="E[35mE[01m"
#结束符
RES="E[0m"
echo -e "$YELLOW$DATE image状态码为:$RES $PURPLE ${PRO_WEB} $RES"
if [ ${PRO_WEB} -eq 200 ];then
echo -e "$GREEN 网站访问正常 $RES"
elif [ ${PRO_WEB} -eq 302 ];then
echo -e "$GREEN 网站已做跳转,访问正常 $RES"
else
echo -e "$RED 网站访问异常,请检查服务 $RES"
fi