Monday, July 11, 2016

Windows 2008 Tomcat Housekeeping

A simple Windows 2008 task to restart Apache Tomcat running in Cumulus Web Services. Doing this nightly is recommended to clean up it's cache files for best performance.

STEP 1: Launch Windows Services, then highlight and copy the Service Name.


STEP 2: Write your batch script as follows:

@echo off
tasklist /SVC | find /i "CumulusWebSolutions"

rem ------ do not stop the Scheduler service if it is not running

if %errorlevel% == 1 goto :startwithoutstop
net stop CumulusWebSolutions
:startwithoutstop
net start CumulusWebSolutions
@echo on



STEP 3: In Windows 2008 Server, launch the Task Scheduler application. Create a new task, than set the general options.


STEP 4: Select the trigger tab and set the times you wish your task to run.


STEP 5: Go to the Actions tab, and enter the name of your batch (.bat) file. Then in the "Start in" field include the path to your file. IMPORTANT: This is not optional! You need to paste the correct path here for your task to run.


STEP 6: Finish the task settings and save the task. Enter your Administrator login to confirm.


STEP 7: Once back in your task list, try a test run of your task to monitor the service. If setup correctly, you will see it automatically stop and restart.