4

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.

migrated from stackoverflow.com Apr 5 '11 at 13:59

This question came from our site for professional and enthusiast programmers.

5

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
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>

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.