How to schedule a tomcat service restart in windows

This tutorial provides a step-by-step guide on how to create a windows task which restarts the tomcat service at a specific time frame.

1. Create a batch file for stopping/starting tomcat

The first step is to create a batch script that stops and starts the tomcat service through the tomcat service name, this tutorial describes in detail how to do this.

2. Create windows scheduler

In order to run the above script automatically, we create a windows task through the following steps:

  • Go to Start => Task Scheduler
  • Right-click “Task Scheduler Library” => “Create Basic Task”
  • Name the task as “Tomcat Restart”, write some description then click Next.
  • Create basic task in windows
  • In the trigger screen, select when do you want this task to run, in our example, we select “Daily”.
  • In the next screen, set the time at which the task executes and keep the “Recur every” field as 1 day, then click Next.Create daily basic task in windows
  • Keep the action as “Start a program”, then click Next.
  • Now put the path of your batch script and keep the optional fields empty, then click Next.Set the program to run in the windows task screen
  • In the last screen, check on “Open the properties dialog for this task ..” checkbox then click Finish.
  • After clicking “Finish“, the “Task Properties” screen appears. In the “Security Options” section, tick on the “Run whether user is logged on or not” radio button and check on the “Run with highest privileges” checkbox as below:Windows task properties
  • Finally, go to the “Settings” tab and check the “If the task fails, restart every” checkbox and set how much time windows should wait before running the task again in case of failure. This step is very important because by default the task won’t run again after failure.
  • Windows task failure

5 1 vote
Article Rating

Hussein Terek

Owner of, I have a passion for software engineering and everything related to Java environment.

Inline Feedbacks
View all comments