LinuxTomcat automatic detection and restart

Source: Internet
Author: User
LinuxTomcat automatically detects and restarts customers' machines and sometimes encounters downtime. although I have configured the Tomcat self-start program on the Linux server, web applications can be automatically deployed when the machine is restarted. However, when the database server and Web application server cannot be started at the same time... linux Tomcat automatically detects and restarts customers' machines and sometimes encounters downtime. although I have configured the Tomcat self-start program on the Linux server, web applications can be automatically deployed when the machine is restarted. However, when the database server and Web application server cannot start at the same time, the Tomcat startup project fails. Finally, a shell script is written to automatically determine whether a tomcat process exists. If no tomcat process exists, restart tomcat. otherwise, no operations are performed and tomcat startup logs are written to the file. The script is as follows: java code #/bin/bash ################################# ############ author zhao yanan # date 2010/08/23 # update 2011/01/10 # Automatic detection and restart tomcat ############ ################################## the script can be written to an automatic task., the execution cycle can be determined based on the start and stop times of tomcat, as shown below, check every 10 minutes between and every day # echo "*/3 0-24 *** root/script/tomcat_check.sh>/root/script/tomcat_check.log 2> & 1 ">/etc/crontab echo ============== ========================== Date PROCESS_NUM = 'PS-ef | grep tomcat | grep -v "grep" | wc-l 'if [$ PROCESS_NUM-lt 1]; then # determine whether a Tomcat process exists. if not, execute the following tasks. otherwise, execute the tasks after else. # Java Environment variables # set jdk Environment variables and set export JAVA_HOME =/usr/local/jdk1.6.0 _ 25 export PATH = $ JAVA_HOME/bin according to your actual situation: $ PATH export CLASSPATH =.: $ JAVA_HOME/lib/dt. jar: $ JAVA_HOME/lib/tools. jar export CATALINA_HOME =/usr/local/tomcat echo "restart tomcat. "$ {CATALINA_HOME}/bin/shutdown. sh # Disable tomcat sleep 5 # wait for tomcat to close, usually 1 ~ Within S, kill-9 'PS aux | grep "/usr/local/tomcat" | grep-v grep | awk '{print $2} ''# after the wait time is over, force the completion of the tomcat process sleep 5 $ {CATALINA_HOME}/bin/catalina. sh run sleep 5 else echo "checked. "# The home page is successfully downloaded and a message indicating that the fi has been checked is displayed.

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.