In linux, tomcat is automatically deployed.

Source: Internet
Author: User

In linux, tomcat is automatically deployed.

Script for automatically deploying tomcat in linux

Because war is often deployed on mongocat, there are often some repetitive tasks to do: stop the service, back up the war package, upload a new war package, and start the service. Simply write a script for automatic deployment.

The script is as follows: autoDeploy. sh:

1 #! /Bin/sh 2 echo '#################### start automatic deployment ########## ########## '3 path = 'pwd' # current path 4 tomcat path = tomcat-7 # specify the tomcat file directory name 5 cd .. /$ tomcatPath/bin # enter the bin directory of tomcat 6 PID =$ (ps-fu 'whoam' | grep tomcat | grep-v grep | awk' {print $2 }') 7 if [-z "$ PID"]; then 8 echo "no tomcat process" 9 else10. /shutdown. sh # Stop tomcat service 11 fi12 sleep 1 # sleep 1s13 cd .. /webapps # enter the tomcat webapps directory 14 rm-fr test # Delete the test file directory 15 mv test. war test. war. $ (date + % Y % m % d) # Back up test16 cp $ path/test under webapps. war. /# copy test. war to webapps path 17 sleep 1 # sleep 1s18 cd .. /bin19. /startup. sh # start tomcat service 20 echo '#################### end of deployment ########## ##########'

Note:

1. Create a directory named autoDeploy and tomcat in the same directory.

(1) Put autoDeploy. sh in the autoDeploy directory

(2) Put the test. war to be deployed in the autoDeploy directory (test. war is the war package to be deployed on tomcat)

2. tomcat Path = tomcat-7 (specify the tomcat file directory name, and change tomcat-7 to the tomcat directory name)

3. Execute autoDepoy. sh to implement automatic deployment.

If the newly created autoDepoy. sh does not have the execution permission, run: chmod + x autoDeploy. sh.

 

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.