How to Start Stop Apache Tomcat Server via Command Line? (Setup as Windows Service)


Apache Tomcat (or simply Tomcat) is an open source web server and servlet container developed by the Apache Software Foundation (ASF). Tomcat implements the Java Servlet and the JavaServer Pages (JSP) specifications from Oracle Corporation, and provides a “pure Java” HTTP web server environment for Java code to run.

I’ve setup tomcat as Windows Service. Running Tomcat as a Windows Service provides a number of benefits that are essential when moving from a development set-up to a production environment.

  • Reliable automatic startup on boot – essential in an environment where you may want to remotely reboot a system after maintenance without worrying about whether your server will come back online.
  • Server startup without active user login – in a data center, it is not reasonable to expect an active login from the system just to run Tomcat. In fact, Tomcat is often run on blade servers that may not even have an active monitor connected to them.  Windows Services are owned by the System, and can be started without an active user.
  • Better Security.
Recently I wanted to start/stop my Tomcat Server via command line as wanted to create quick shall script to do it. This official documentation provided below commands in the form of “//XX// ServiceName

The available command line options are:

  • //TS// Run the service as console application This is the default operation. It is called if the no option is provided. The ServiceName is the name of the executable without exe suffix, meaning Tomcat6
  • //RS// Run the service Called only from ServiceManager
  • //SS// Stop the service
  • //US// Update service parameters
  • //IS// Install service
  • //DS// Delete service Stops the service if running

But rather doing it this way I found below commands very useful and simple.

Other must read articles:

1) Windows (if Tomcat is setup as Windows Service)

  • To Start server: <Tomcat Root>/bin>Tomcat7.exe start
  • To Stop server: <Tomcat Root>/bin>Tomcat7.exe stop

2) Windows (if you have downloaded binaries as .zip)

  • To Start server: <Tomcat Root>/bin>startup.bat
  • To Stop server: <Tomcat Root>/bin>shutdown.bat

3) Mac/Linux/Unix (if you have downloaded binaries as .zip)

  • To Start server: <Tomcat Root>/bin>
  • To Stop server: <Tomcat Root>/bin>
Have anything to add to this article? Please chime in and join the conversion.

Enjoyed this post?

Be sure to subscribe to the Crunchify newsletter and get regular updates about awesome posts just like this one and more! Join more than 13000 subscribers!

  • Manoj

    thanks for your help………Now it’s working fine…

  • Eric

    Thanks, it worked for me on my CentOS 7. I found that if I create systemd unit file I will be able to start/stop/restart Tomcat using systemctl. It is really hard to find a fully working script, however I spend few sleepless nights and found one. Thanks for sharing this article.

    • App Shah

      You are welcome Eric. Thanks for taking a time to drop a line.

  • Pablo Gilvan

    Thank you!

  • Hitesh

    Thanks for this great tutorial. Appreciate your work.

    • App Shah


  • Website Domain

    We’re a gaggle of volunteers and opening a new scheme in our community. Your web site offered us with valuable information to work on. You’ve performed an impressive activity and our whole community can be grateful to you.

    • App Shah

      Thanks much for nice word. Keep visiting.

  • Fat Loss Factor Review

    WOW just what I was searching for. Came here by searching for Fat Loss Factor Review

    • App Shah

      Awesome. Glad you like it.

  • javaexp

    I would like to add that we can also create multiple tomcat instances by using the java based portable utility which I developed for automating the steps required to edit the server config files.

    • App Shah

      Awesome. Thanks for sharing.

    • App Shah

      Thanks for sharing link..