Interested to know how people usually check to see if Tomcat is running on a Unix environs.

I either check that the process is running using

                ps -ef | grep coffee ps -ef | grep logging                              

or i bank check that the port number is active

                netstat -a | grep 8080                              

is at that place a better fashion of checking that Tomcat is running? The above seem to exist to exist a 'hacky' way of checking that Tomcat is running.

asked October 15, 2010 at 16:25

user avatar

i

On my linux system, I starting time Tomcat with the startup.sh script. To know whether information technology is running or not, i employ

                ps -ef | grep tomcat                              

If the output issue contains the whole path to my tomcat binder, then it is running

answered Aug 9, 2012 at 3:49

user avatar

effort this instead and considering it needs root privileges use sudo

                  sudo service tomcat7 status                                  

user avatar

eeadev

3,512 vii gold badges 37 silver badges 93 statuary badges

answered Jan xxx, 2014 at 8:08

user avatar

three

Why grep ps, when the pid has been written to the $CATALINA_PID file?

I have a cron'd checker script which sends out an email when tomcat is downwardly:

                  kill -0 `cat $CATALINA_PID` > /dev/nil ii>&1 if [ $? -gt 0 ] then     echo "Check tomcat" | mailx -s "Tomcat not running" support@dom.com fi                                  

I gauge you could also use wget to cheque the health of your tomcat. If yous accept a diagnostics folio with user load etc, y'all could fetch it periodically and parse it to determine if anything is going wrong.

user avatar

erip

15.3k 10 gold badges 61 silverish badges 113 bronze badges

answered Oct 16, 2010 at 23:59

user avatar

4

netstat -lnp | grep 8080 would probably exist the best manner, if you lot know Tomcat's listening port. If you want to exist certain that is is functional, you will have to establish a connectedness and transport an HTTP asking and get a response. You can do this programatically, or using any web browser.

user avatar

fluffyBatman

6,004 3 gold badges 21 argent badges 24 bronze badges

answered Oct 15, 2010 at 16:33

user avatar

1

You can check the status of tomcat with the following means:

                ps -ef | grep tomcat                              

This will return the tomcat path if the tomcat is running

                netstat -a | grep 8080                              

where 8080 is the tomcat port

answered Dec 27, 2013 at 7:24

user avatar

If tomcat is installed locally, blazon the following url in a browser window: { localhost:8080 }

This volition display Tomcat habitation folio with the following message.

If you're seeing this, you lot've successfully installed Tomcat. Congratulations!

If tomcat is installed on a separate server, you lot can type replace localhost by a valid hostname or Iess where tomcat is installed.

The above applies for a standard installation wherein tomcat uses the default port 8080

answered Mar 10, 2013 at 0:10

user avatar

3

Create a Crush script that checks if tomcat is up or downwardly and set a cron for sh to arrive check every few minutes, and auto get-go tomcat if downwardly. Sample Snippet of code below

                  TOMCAT_PID=$(ps -ef | awk '/[t]omcat/{impress $2}') echo TOMCAT PROCESSID $TOMCAT_PID  if [ -z "$TOMCAT_PID" ] and so     repeat "TOMCAT NOT RUNNING"     sudo /opt/tomcat/bin/startup.sh else    echo "TOMCAT RUNNING" fi                                  

answered Mar 28, 2018 at 5:43

user avatar

two

I always practice

                  tail -f logs/catalina.out                                  

When I encounter there

                  INFO: Server startup in 77037 ms                                  

then I know the server is upwards.

answered Jul 2, 2014 at eight:59

user avatar

ane

wget url or whorl url where url is a url of the tomcat server that should exist available, for example: wget http://localhost:8080. Then check the go out code, if it's 0 - tomcat is up.

answered Jan 28, 2016 at 7:12

user avatar

I've found Tomcat to be rather finicky in that a running process or an open up port doesn't necessarily hateful information technology'south actually handling requests. I usually try to catch a known page and compare its contents with a precomputed expected value.

answered October 15, 2010 at 16:33

user avatar

Are y'all trying to ready an alert organization? For a simple "heartbeat", do a HTTP asking to the Tomcat port.

For more than elaborate monitoring, y'all can fix up JMX and/or SNMP to view JVM stats. We run Nagios with the SNMP plugin (bridges to JMX) to check Tomcat memory usage and asking thread puddle size every x-15 minutes.

http://tomcat.apache.org/tomcat-6.0-doc/monitoring.html

Update (2012):

We have upgraded our systems to use "monit" to check the tomcat process. I really like it. With very little configuration it automatically verifies the service is running, and automatically restarts if it is not. (sending an email alarm). It can integrate with the /etc/init.d scripts or bank check by process name.

answered Oct 25, 2010 at ii:13

user avatar

Since my tomcat instances are named every bit tomcat_ . For example. tomcat_8086, I use

#

                ps aux | grep tomcat                              

Other method is using nc utility

nc -l 8086 (port number )

Or

ps aux | grep java

answered Sep 23, 2016 at 12:06

user avatar

Effort this command

                ps -ef | awk '/[t]omcat/{print $2}'                              

Information technology will return the pid if tomcat is running.

answered Sep 8, 2017 at ix:28

user avatar

tomcat.sh helps yous know this easily.

tomcat.sh usage medico says:

no statement: brandish the process-id of the tomcat, if information technology's running, otherwise do aught

Then, run command on your command prompt and check for pid:

$ tomcat.sh

user avatar

Wade

425 five silver badges 6 bronze badges

answered Dec 10, 2018 at seven:27

user avatar

                $ sudo netstat -lpn |grep :8080                              

To cheque the port number

                $ ps -aef|grep tomcat                              

Is any tomcat is running under the server.

                tsssinfotech-K53U infotech # ps -aef|grep tomcat                              

root 9586 9567 0 11:35 pts/6 00:00:00 grep --color=auto tomcat

user avatar

Dovydas Ĺ opa

two,252 8 aureate badges 25 silver badges 32 statuary badges

answered April 22, 2016 at six:03

user avatar

Basically you want to examination

  1. Connectivity to your tomcat case
  2. Gather some basic statistics
  3. Whether the unix procedure is running

I volition evaluate kickoff 2 options as the tertiary ane has been sufficiently answered already.

easiest is simply to develop a webpage on your WebApp that gathers some basic metrics, and have a client that can read the results or notice connectivity issues.

For doing and so, you have several problems

  • Stand up Lone client in Java
  • Using Scroll.

answered Oct 25, 2017 at 18:11

user avatar

Hither are my two cents.

I have multiple tomcat instances running on different ports for my cluster setup. I use the following control to check each processes running on different ports.

                /sbin/fuser 8080/tcp                              

Supervene upon the port number as per your need.

And to impale the process utilise -grand in the above command.

  • This is much faster than the ps -ef mode or any other commands where you call a command and call another grep on top of information technology.
  • Works well with multiple installations of tomcat ,Or any other server that uses a port every bit a matter of fact running on the same server.

The equivalent command on BSD operating systems is fstat

answered Nov 28, 2017 at 8:50

user avatar

Non the reply you lot're looking for? Browse other questions tagged tomcat or ask your own question.