Optimized scripts for automatic backup, automatic restart of Tomcat
#!/bin/bashnew_war= "Mobile.war" project_name= "tomcat-app1" #创建临时文件夹tempDirName = ' date ' +%y%m%d%h%m%s ' tempdirname= "Bak/mobile-${tempdirname}" echo "Ready to create Temp folder: ${tempdirname}" ' MkDir ${tempdirname} ' #停止Tomcat ' sh/usr/tomcat/${ Project_name}/bin/shutdown.sh ' echo ' Stop tomcat ... "#暂停4S等待Tomcat停止sleep 4s# kill the Tomcat process (if it hasn't stopped) process= ' Ps-ef|grep $ {project_name}|grep-v grep|grep-v Ppid|awk ' {print $} ' for I-${process} do echo ' Terminate process ${project_name} process ID = [${i}] "kill-9 ${i}done# move War file to Temp folder ' Mv/usr/tomcat/${project_name}/webapps/root.war ${tempdirname} ' #移动日志文件, temporarily do not #删除ROOT文件夹echo "Delete ROOT folder" ' Rm-rf/usr/tomcat/${project_name}/webapps/root ' #拷贝发布包到webappsecho "copy release package to WebApps" ' CP ${ New_war}/usr/tomcat/${project_name}/webapps/root.war ' #启动Tomcat ' sh/usr/tomcat/${project_name}/bin/startup.sh ' echo "Start Tomcat" #等待ROOT文件夹生成echo "Wait for ROOT folder generation" while:d OIF [-D "/usr/tomcat/${project_name}/webapps/root"]thenbreak; Fiecho-e "=\c" Sleep 1sdoneecho "completed O (∩_∩) o~"
Shell automatic Backup Deployment New Project (2)