Shell automatic backup Deployment New Project (2)

Source: Internet
Author: User

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)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.