6

This has been bugging me for a while.

In my JSF development cycle, I do a lot of tomcat reload and sometimes to the point of restarting tomcat. I notice that at times, shutting down tomcat using shutdown.sh doesn't work, because when starting it via startup.sh says the address is already in use for port 8080. And in the linux shell, I have to do something like this:

ps auwx | grep -i tomcat
kill -9 <tomcatPid>

Is there any way to be able to shutdown tomcat cleanly, like the the tomcat service in Windows ?

I'm currently using opensuse linux 11.2, and I don't add my tomcat onto my services yet. Still starting and shutdown it manually from the shell.

Scott Pack
  • 14,907
  • 10
  • 53
  • 83
Bertie
  • 173
  • 1
  • 1
  • 7

2 Answers2

6

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
anubhava
  • 411
  • 4
  • 8
0

The clean way to shut it down is kill <tomcatPid>. That will start the JVM shutdown process including the servlet context destroy mechanism. On rare occasions the JVM will get stuck in the shutdown process and you will need to use kill -9 <tomcatPid> to kill the process.

So for example:

ps auwx | grep -i tomcat
kill <tomcatPid>
sleep 10   # This value is dependent how long it takes for your app to shut down
ps auwx | grep -i tomcat
if tomcat is still alive
    kill -9 <tomcatPid>
sourcedelica
  • 126
  • 2