1

I am doing the following to determine if Tomcat is running:

$ whoami
voops
voops@esavo00:~/apache-tomcat-7.0.57/bin#
$ ps -ef | grep -i tomcat | grep -v grep
voops     8973     1  0 Apr22 ?        00:00:40 /usr/local/jdk1.7.0_67/bin/java -Djava.util.logging.config.file=/home/voops/apache-tomcat-7.0.57/conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Djava.endorsed.dirs=/home/voops/apache-tomcat-7.0.57/endorsed -classpath /home/voops/apache-tomcat-7.0.57/bin/bootstrap.jar:/home/voops/apache-tomcat-7.0.57/bin/tomcat-juli.jar -Dcatalina.base=/home/voops/apache-tomcat-7.0.57 -Dcatalina.home=/home/voops/apache-tomcat-7.0.57 -Djava.io.tmpdir=/home/voops/apache-tomcat-7.0.57/temp org.apache.catalina.startup.Bootstrap start

My reading of the above is that tomcat is running as a process owned by the currently logged-in user (voops). I then do a:

$ netstat -a | grep 8080

.. but nothing is grepped.

My server.xml file declares the following element:

<Connector port="8080" protocol="HTTP/1.1"
           connectionTimeout="20000"
           redirectPort="8443" />

This is what netstat -an | grep 8080 shows:

$ netstat -an | grep 8080
tcp        0      0 0.0.0.0:8080                0.0.0.0:*                   LISTEN
tcp        1      0 131.176.161.23:44535        131.176.161.23:8080         CLOSE_WAIT
tcp        1      0 131.176.161.23:54600        131.176.161.23:8080         CLOSE_WAIT
tcp        1      0 131.176.161.23:51667        131.176.161.23:8080         CLOSE_WAIT
tcp        1      0 131.176.161.23:50348        131.176.161.23:8080         CLOSE_WAIT         
...  5 more lines similar to the one above
  • Maybe it's not listening on port 8080? What does netstat -tap | grep -i -e tomcat -e javasay? – FloHimself Apr 23 '15 at 7:32
  • @FloHimself it is listening on 8080 as I tail -f the catalina.out file and have seen: INFO: Starting ProtocolHandler ["http-bio-8080"] – Marcus Junius Brutus Apr 23 '15 at 7:43
  • @FloHimself Also the server.xml file declares a Connector for HTTP/1.1 on port 8080. – Marcus Junius Brutus Apr 23 '15 at 7:51
  • 3
    try netstat -an to get numeric result, otherwise try netstat -a|grep http-alt – Lambert Apr 23 '15 at 7:56
  • 1
    @MarcusJuniusBrutus what does netstat show when adding the -p flag? This should show PID and name of the process listening on 8080 – FloHimself Apr 23 '15 at 9:06
3

In case the comments to the question were not clear enough, I am adding an answer here, along with a few Pointers not mentioned in those comments.

"Why doesn't Tomcat doesn't show up when I grep netstat's output for 8080 ?"
Short Answer :
Because Port Number 8080 is getting converted to string http_alt, which will not match the grep pattern.

Details :
From https://en.wikipedia.org/wiki/List_of_TCP_and_UDP_port_numbers , we can see that Port 8080 is Officially "HTTP alternate (http_alt)—commonly used for Web proxy and caching server, or for running a Web server as a non-root user".
Basically, netstat will show "http-alt" for Port 8080 with Default Display.

When using netstat -n, the Port numbers (like 8080 for http-alt) will be shown, & you will be able to grep it. Process ID of the listening Process will be shown when running netstat with -p.

So use netstat -pa | grep http-alt or netstat -pan | grep :8080 to see the tomcat Entry.

Alternately, use lsof -P | grep :8080 which will also show the Process ID & Process Name owning the socket which is listening on Port 8080. Here -P will prevent Port Numbers getting converted to strings (like 8080 for http-alt)

Another alternative is nmap $SERVER or namp localhost, which will show all open ports including 8080, when tomcat is running fine.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.