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 CodeAttach 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.