The command netstat -nlp
will show you what is listening:
]# netstat -nlp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 127.0.0.1:8005 0.0.0.0:* LISTEN 13940/java
tcp 0 0 0.0.0.0:8009 0.0.0.0:* LISTEN 13940/java
tcp 0 0 0.0.0.0:8080 0.0.0.0:* LISTEN 13940/java
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 3377/sshd
The lsof
command on the pid of the tomcat process will show something similar:
java 13940 root 35r CHR 1,9 942 /dev/urandom
java 13940 root 36r CHR 1,9 942 /dev/urandom
java 13940 root 38u IPv4 31050 TCP *:8009 (LISTEN)
java 13940 root 39u IPv4 31053 TCP 127.0.0.1:8005 (LISTEN)
When you run shutdown.sh
you should see traffic go to port 8005:
[root@test001 ~]# tcpdump -i lo 'port 8005'
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on lo, link-type EN10MB (Ethernet), capture size 96 bytes
20:11:22.168395 IP test001.36696 > test001.8005: S 2859727005:2859727005(0) win 32792 <mss 16396,sackOK,timestamp 20428874 0,nop,wscale 7>
20:11:22.168922 IP test001.8005 > test001.36696: S 2855491174:2855491174(0) ack 2859727006 win 32768 <mss 16396,sackOK,timestamp 20428874 20428874,nop,wscale 7>
20:11:22.168598 IP test001.36696 > test001.8005: . ack 1 win 257 <nop,nop,timestamp 20428874 20428874>
20:11:22.171127 IP test001.36696 > test001.8005: P 1:2(1) ack 1 win 257 <nop,nop,timestamp 20428877 20428874>
20:11:22.171144 IP test001.8005 > test001.36696: . ack 2 win 256 <nop,nop,timestamp 20428877 20428877>
20:11:22.171443 IP test001.36696 > test001.8005: P 2:3(1) ack 1 win 257 <nop,nop,timestamp 20428877 20428877>
20:11:22.171453 IP test001.8005 > test001.36696: . ack 3 win 256 <nop,nop,timestamp 20428877 20428877>
20:11:22.171686 IP test001.36696 > test001.8005: P 3:4(1) ack 1 win 257
- Check that
localhost
resolves e.g. it's in /etc/hosts.
- Check that you are not running the Ubuntu Firewall.
- Post your
netstat -nlp
output if you can.
- Try
telnet localhost 8005
or telnet 127.0.0.1
You can avoid 2 commands by simply running:
pkill -f catalina
to gracefully kill process matching with text catalina.
And to check whether catalina process is still running you can then do:
pgrep -fl catalina
And finally to kill with brute force try:
pkill -9 -f catalina
Best Answer
I often have this happen. It depends on the webapps you are running. If you have threads that are not running in daemon mode they must stop before Tomcat shuts down. My logs will say "Waiting to deallocate thread" but Tomcat will never stop.
When you've installed Tomcat on a production system, you have to put a script in /etc/init.d that actually kills the process if it doesn't stop after 30 seconds. Never just shut down and restart Tomcat from the command line with the standard scripts in $CATALINA_HOME/bin or you may get two instances running.