码迷,mamicode.com
首页 > 其他好文 > 详细

批处理TOMCAT8.0自动重启任务

时间:2018-11-26 20:16:24      阅读:221      评论:0      收藏:0      [点我收藏+]

标签:The   RoCE   ogr   java_home   start   strong   tom   back   jdk1.8   

@echo
title tomcat重启

 

set num=7001  //端口号,根据tomcat的设置项设置
set JAVA_HOME=D:\software\Java\jdk1.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 Foundation\Tomcat 8.0\logs" /s /m *.log /d -5 /c "cmd /c del @path
forfiles /p "D:\software\ Apache Software Foundation\Tomcat 8.0\logs" /s /m *.txt /d -5 /c "cmd /c del @path

forfiles /p "D:\software\ Apache Software Foundation\Tomcat 8.0\work" /s /m *.log /d -5 /c "cmd /c del @path
forfiles /p "D:\software\ Apache Software Foundation\Tomcat 8.0\work" /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!

批处理TOMCAT8.0自动重启任务

标签:The   RoCE   ogr   java_home   start   strong   tom   back   jdk1.8   

原文地址:https://www.cnblogs.com/Stir-friedEggplant/p/10021634.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!