2

I have got some problems with my tomcat instance. I am using apache-tomcat-6.0.20 for linux.My OS is CENTOS

when I execute command

# bin/shutdown.sh

It does not close the process that is running the tomcat.

Can any body please give me some idea; what is happening with the process.

4

I've seen this problem a few times with Tomcat. A couple of things that might help:

  1. Give it some time to make sure the process really isn't shutting down; the Tomcat shutdown script tries to do a clean shutdown, and that can take a while if the Tomcat server had a large number of threads open when you called the shutdown script. If it takes more than 5 to 10 minutes, you probably have some other issue.
  2. Look in the log file (usually logs/catalina.out under the main Tomcat directory) - 9 times out of 10 you'll at least get a pointer to the underlying problem. Go head and post the error message here if you need more help.
  • 2
    +1. Mine takes forever, too. – Matt Simmons May 11 '10 at 16:05
  • confirmed for "If it takes more than 5 to 10 minutes..." thanks! – Nguyen Van Vinh Feb 25 '16 at 11:13
0

Does your system fail to shutdown? (ie: Hang?) If not, then it's definitely shutting down the process, just not in the way you might want. And was the startup script something you wrote, or came in a package? Is it correct to assume you've done some work with the /etc/init.d scripts? You're going to want to give us a bit more infomation.

Odds are, you need to have the process registered with chkconfig. Just putting Kscripts in /etc/rc#.d/ isn't sufficient, as I don't believe they get called if chkconfig doesn't know about them.

Essentially, your script needs lines at the top stating

# chkconfig: 345 99 10
# description: This is what my script does.

The first line states the runlevels this should be started on, as well as the priority startup and shutdown levels. (It would create S99 scripts in /etc/rc3.d, /etc/rc4.d, and /etc/rc5.d, and K10 scripts in all the rest)

On top of this, chkconfig will do a check in /var/lock/subsys/ to see if there's a lockfile out there for your service. So touch a file the same name as your service in that directory when it starts, and remove it when it quits.

Assuming you've got the above items in your script, it must be registered with chkconfig. In order to add a script, do chkconfig --add <name>. Just make sure the script is in /etc/init.d/ with the proper name.

  • Hi I have created a deploy script which is designed to copy war file from a predefined network location and deploy it in the tomcat location. This script first try to shutdown the tomcat process by calling "bin/shutdown.sh". Then it removes old war file from the webapp folder. After this script moves and copy war file. Once the war file is copied in the webapp folder, it tries to restart the tomcat server. But it fails; because it does not stopped on last shut down call. To shutdown and start tomcat I am using scripts found in package. – vijay.shad Feb 24 '10 at 7:25
  • Vijay does Tomcat shutdown if you manually run bin/shutdown.sh, or will Tomcat not shutdown irrespective of whether you ask it to manually or via your deployment script? – David Harrison Mar 26 '10 at 2:32
0

Do you have profiling installed? Tomcat has a known issue with profiling in that it doesn't shut down properly if it is installed. There is a work-around mod to the shutdown.sh script but I am still looking for it myself. This is in Tomcat 7, don't know if it's also in Tomcat 6.

0

The best way to shutdown tomcat is by using shutdown script. But many people face issues with it and end up killing the process manually.

Shutdown script works properly only if the scripts that will be touched during shutdown process are either :

  1. owned by the user.
  2. owned by the PRIMARY group of the user

this will not work if the user belongs in secondary groups.

In case you have to choose to kill the process, you can use the below mentioned script to make it as a single command (finding the process and then killing it). Just put in inside a script and run it whenever you want to kill running tomcat.

#Finds the tomcat process id
ps aux | grep tomcat | grep JavaVirtualMachines | awk -F  " " '{print $2}' > tomcatProcessID

#Kills the process id returned from above mentioned command.
kill -9 `cat tomcatProcessID` && tput setaf 3 && echo "Tomcat killed Successfully" ;rm -rf tomcatProcessID

#Not a mandatory command.
#Used to show all the remaining processes with 'tomcat' keyword in it.
#To inform on the console that the tomcat (running ess or indexer) is killed.
ps aux | grep tomcat | grep -v grep | grep -v killtomcat

If you like, you can add ps aux | grep tomcat | grep -v grep | grep -v killtomcat at the end to show the remaining tomcat processes after killing is attempted.

I hope it helps.

Your Answer

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