脚本实现目的:
利用svn更新war包同时删除缓存。
彻底关闭tomcat,用指定用户启动tomcat。
考虑事项:
执行函数为:zzz01
tomcat路径为/usr/local
启动tomcat用户为www
注意xargs的使用
#!/bin/bash
function zzz01(){
su - www -c "rm -rf /usr/local/tomcat_imp_stockRecord1/webapps/imp-stockRecord-web"
su - www -c "rm -rf /usr/local/tomcat_imp_stockRecord1/work/*"
su - www -c "svn up /usr/local/tomcat_imp_stockRecord1/webapps/imp-stockRecord-web.war"
su - www -c "sh /usr/local/tomcat_imp_stockRecord1/bin/startup.sh"
}
sh /usr/local/tomcat_imp_stockRecord1/bin/shutdown.sh> /dev/null 2>&1
sh /usr/local/tomcat_imp_stockRecord1/bin/shutdown.sh> /dev/null 2>&1
sleep 3
num=`ps -ef|grep tomcat_imp_stockRecord1|grep -v grep|awk '{print $2}'`
#echo $num
if [ "$num" = "" ];then
echo "关闭成功并更新中======================="
zzz01
else
echo $num |xargs kill
sleep 2
zzz01
fi
转载于:https://blog.51cto.com/jingfeng/1879899