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

apache tomcat crunchify 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>startup.sh
  • To Stop server: <Tomcat Root>/bin>shutdown.sh
Have anything to add to this article? Please chime in and join the conversion.
twitter How to Start Stop Apache Tomcat Server via Command Line? (Setup as Windows Service)facebook How to Start Stop Apache Tomcat Server via Command Line? (Setup as Windows Service)google How to Start Stop Apache Tomcat Server via Command Line? (Setup as Windows Service)pinterest How to Start Stop Apache Tomcat Server via Command Line? (Setup as Windows Service)tumblr How to Start Stop Apache Tomcat Server via Command Line? (Setup as Windows Service)buffer How to Start Stop Apache Tomcat Server via Command Line? (Setup as Windows Service)

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 8000 subscribers!

  • Pablo Gilvan

    Thank you!

  • http://parmarhh.wordpress.com/ Hitesh

    Thanks for this great tutorial. Appreciate your work.

    • http://crunchify.com/ Arpit

      Thanks.

  • 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.

    • http://crunchify.com/ Arpit 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

    • http://crunchify.com/ Arpit Shah

      Awesome. Glad you like it.

  • http://www.javaexperience.com/ 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.

    • http://crunchify.com/ Arpit Shah

      Awesome. Thanks for sharing.

    • http://crunchify.com/ Arpit Shah

      Thanks for sharing link..