@echo
title tomcat重启
set num=7001 //端口号,根据tomcat的设置项设置
set JAVA_HOME=D:softwareJavajdk1.8.0_131 //jkd位置
set CATALINA_HOME="D:/software/Apache Software Foundation/Tomcat 8.0" //tomcat位置(注:文件夹的空格问题,该文件中不做添加,将其添加到环境变量中)
echo 删除tomcat日志文件
//删除文件方式1(删除定时天数中的文件)
forfiles /p "D:software Apache Software FoundationTomcat 8.0logs" /s /m *.log /d -5 /c "cmd /c del @path
forfiles /p "D:software Apache Software FoundationTomcat 8.0logs" /s /m *.txt /d -5 /c "cmd /c del @path
forfiles /p "D:software Apache Software FoundationTomcat 8.0work" /s /m *.log /d -5 /c "cmd /c del @path
forfiles /p "D:software Apache Software FoundationTomcat 8.0work" /s /m *.txt /d -5 /c "cmd /c del @path
//删除文件方式2
del /f /s /q "D:/software/Apache Software Foundation/Tomcat 8.0/logs/*.*"
del /f /s /q "D:/software/Apache Software Foundation/Tomcat 8.0/work/*.*"
//删除文件夹
rmdir /s /q "D:/software/Apache Software Foundation/Tomcat 8.0/work/work1"
rmdir /s /q "D:/software/Apache Software Foundation/Tomcat 8.0/work/Catalina"
echo 删除tomcat日志文件完成!
//根据端口号进行判断
for /f "tokens=3 delims=: " %%a in ('netstat -an') do (
if "%%a"=="%num%" goto en
)
if not "%%a"=="%num%" goto en1
:en
echo.Checking For local%NUM%Port is Opening...
echo 1.End The JAva program!
call "D:/software/Apache Software Foundation/Tomcat 8.0/bin/shutdown.bat"
echo 2.Kill The Process!
taskkill /f /im java.exe /t
echo 3.MAke The Service To Be Running After Ten Seconds!
ping -n 10 localhost > nul
echo 4.MAke The Service To Be Running!
call "D:/software/Apache Software Foundation/Tomcat 8.0/bin/startup.bat"
echo Over!
:en1
echo.Checking For local%NUM%Port is Not Opening...
echo.Starting Tomcat Program...
echo 1.MAke The Service To Be Running!
call "D:/software/Apache Software Foundation/Tomcat 8.0/bin/startup.bat”
echo.Starting Succes!
echo.OK!