Script implementation purposes:
Update the war package with SVN to delete the cache at the same time.
Turn Tomcat off completely and start Tomcat with the specified user.
Considerations:
The execution function is: zzz01
The Tomcat path is/usr/local
Start tomcat user for www
Note the use of 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 $} '
#echo $num
If ["$num" = ""];then
echo " close successfully and update in ======================="
Zzz01
Else
echo $num |xargs Kill
Sleep 2
Zzz01
Fi
This article is from the "Ten Years Sword-Breeze" blog, please be sure to keep this source http://jingfeng.blog.51cto.com/9152964/1879899
Tomcat Auto-Updated version of the script