Windows server uses the batch processing script to determine the port, start tomcat, and batch process tomcat

Source: Internet
Author: User

Windows server uses the batch processing script to determine the port, start tomcat, and batch process tomcat

The tomcat on the Windows server always hangs out from time to time. Therefore, the scheduled operation script is used to determine whether port tomcat80 is running. If it is run, it is skipped. If it is down, tomcat is started, solve the Problem of business data flow loss caused by abnormal tomcat mounting.The script is used.

1. Assign environment variable 1 to tomcat. variable name: CATALINA_HOME 2 path: C: \ Program Files \ Java \ apache-tomcat-8.0.35View Code

: Final interpretation is owned by chenglee: Thankyou @ echo off & title Checking For System, Do Not Switch Off, Thankyou... set num = 8090for/f "tokens = 3 delims =:" % a in ('netstat-any ') do (if "% a" = "% num %" goto en) if not "% a" = "% num %" goto en1: enecho. checking For local % NUM % Port is Opening... pauseexit: en1echo. checking For local % NUM % Port is Not Opening... echo. starting Tomcat Program... call "% CATALINA _ HOME % "\ bin \ startup. batecho. Starting Succes! Echo. OK! Pauseexit

  

3. Choose scheduler 1 Control Panel> Management Tools> scheduler Task 2 and create a new scheduler.View Code

Attach my win10 plan

 

The script checks whether port 80 is in netstat. If port 80 is in netstat, it indicates that tomcat is running. At this time, it does not perform any operations. If port 80 is not in netstat, it simply crashes and starts tomcat. Of course, you can change the tomcat port to another port.

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.