Javascript required
Skip to content Skip to sidebar Skip to footer

How to Check if Tomcat Is Installed on Linux

How to Check if Tomcat is already running

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.

If you have any of below questions then you are at right place:

  • Several ports (8080, 8081, 8082) required by Tomcat Server at localhost are already in use
  • Tomcat Server Error – Port 8080 already in use
  • port 8080 required is in use
  • port 8080 already in use eclipse
  • how to stop port 8080 in windows

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.

Benefit-1) Setup reliable automatic startup on boot

  • Essential in an environment where you may want to remotely reboot a Java System after maintenance without worrying about whether your server will come back online.

Benefit-2) Setup Tomcat 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.

Benefit-3) Better Security

Recently I wanted to start/stop my Tomcat Server via command line as wanted to create quick shall script to do it. Official documentation provided below commands in the form of //XX// ServiceName

Apache Tomcat Startup Scripts - Crunchify

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.

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

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

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

  • To Start server: <Tomcat Root>/bin>catalina.bat start
  • To Stop server: <Tomcat Root>/bin>catalina.bat stop

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

  • To Start server: <Tomcat Root>/bin>./catalina.sh start
  • To Stop server: <Tomcat Root>/bin>./catalina.sh stop

Below are all catalina.sh command parameters:

Usage : catalina . sh ( commands . . . )

commands :

debug Start Catalina in a debugger

debug -security Debug Catalina with a security manager

jpda start Start Catalina under JPDA debugger

run Start Catalina in the current window

run -security Start in the current window with security manager

start Start Catalina in a separate window

start -security Start in a separate window with security manager

stop Stop Catalina , waiting up to 5 seconds for the process to end

stop n Stop Catalina , waiting up to n seconds for the process to end

stop -force Stop Catalina , wait up to 5 seconds and then use kill -KILL if still running

stop n -force Stop Catalina , wait up to n seconds and then use kill -KILL if still running

configtest Run a basic syntax check on server . xml - check exit code for result

version What version of tomcat are you running ?

Startup Screenshot:

Tomcat Server started - Crunchify Tips

How to check if Tomcat is already running and kill existing tomcat process.

Step-1) Find out the process using command ps -ef | grep tomcat

bash-3.2 $ ps -ef | grep tomcat

502 56188 1 0 7 : 31PM ttys001 0 : 04.23 /Library/Java/JavaVirtualMachines/jdk1 . 8.0_51.jdk/Contents/Home/bin/java -Djava . util . logging . config . file=/Users/appshah/Downloads/apache-tomcat-8.5.4/conf/logging . properties -Djava . util . logging . manager=org . apache . juli . ClassLoaderLogManager -Djdk . tls . ephemeralDHKeySize=2048 -classpath /Users/appshah/Downloads/apache-tomcat-8.5.4/bin/bootstrap . jar :/Users/appshah/Downloads/apache-tomcat-8.5.4/bin/tomcat-juli . jar -Dcatalina . base=/Users/appshah/Downloads/apache-tomcat-8.5.4 -Dcatalina . home=/Users/appshah/Downloads/apache-tomcat-8.5.4 -Djava . io . tmpdir=/Users/appshah/Downloads/apache-tomcat-8.5.4/temp org . apache . catalina . startup . Bootstrap start

502 56618 55587 0 7 : 34PM ttys001 0 : 00.00 grep tomcat

Here 2nd column value is a process ID. In our case it's 56188.

You could visit link http://localhost:8080 and you should see welcome page.

Welcome Tomcat Page - Crunchify

Step-2) Kill process using command kill -9 <process ID>

Here, 56188 is a process ID which we got it from step-1.

Now, linkhttp://localhost:8080/ shouldn't be working for you.

Share:

I'm an Engineer by profession, Blogger by passion & Founder of Crunchify, LLC, the largest free blogging & technical resource site for beginners. Love SEO, SaaS, #webperf, WordPress, Java. With over 16 millions+ pageviews/month, Crunchify has changed the life of over thousands of individual around the globe teaching Java & Web Tech for FREE.

How to Check if Tomcat Is Installed on Linux

Source: https://crunchify.com/how-to-start-stop-apache-tomcat-server-via-command-line-setup-as-windows-service/