LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 03-14-2013, 11:05 AM   #1
BhaktiK
LQ Newbie
 
Registered: Mar 2013
Posts: 3

Rep: Reputation: Disabled
stop script used to stop tomcat server is working intermittently


Hi All,
I am very much new to linux and to this forum.
I am working on one issue for a customer where they have 10 Red Hat Linux 5.5 64 bits servers. They want to stop the tomcat process using the stop script (the script uses 'kill -15')
On some servers, the script works fine and stops the tomcat process within seconds.
On some servers, sometimes it stops quickly, sometimes it keeps running for minutes and finally customer has to use 'kill -9' command to stop tomcat. Logs are not indicating anything.

Do you have any idea why there is an intermittent behaviour of this script?
How can we catch it in logs etc?

Reg,
Bhakti
 
Old 03-14-2013, 11:32 AM   #2
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 22,090

Rep: Reputation: 5901Reputation: 5901Reputation: 5901Reputation: 5901Reputation: 5901Reputation: 5901Reputation: 5901Reputation: 5901Reputation: 5901Reputation: 5901Reputation: 5901
Quote:
Originally Posted by BhaktiK View Post
Hi All,
I am very much new to linux and to this forum. I am working on one issue for a customer where they have 10 Red Hat Linux 5.5 64 bits servers. They want to stop the tomcat process using the stop script (the script uses 'kill -15')
On some servers, the script works fine and stops the tomcat process within seconds.
On some servers, sometimes it stops quickly, sometimes it keeps running for minutes and finally customer has to use 'kill -9' command to stop tomcat. Logs are not indicating anything.

Do you have any idea why there is an intermittent behaviour of this script? How can we catch it in logs etc?
Since your customers are using Red Hat enterprise, have they checked the Red Hat knowledebase for details, or called Red Hat??

The 'problem' doesn't exist...there is no problem in what you described, and if you read the man pages on kill, and looked up what the different signals mean, you'd see why. The "-15" tells the process to stop what its doing, and end itself. If the process is in the middle of something, it will complete whatever operation it's performing, then terminate. The "-9" doesn't care....it ends right then, maybe with corrupting/losing data, maybe not. So depending on what tomcat is doing, it'll either wait or not.
 
Old 03-15-2013, 07:17 AM   #3
BhaktiK
LQ Newbie
 
Registered: Mar 2013
Posts: 3

Original Poster
Rep: Reputation: Disabled
Script to stop tomcat server works intermittently

Quote:
Originally Posted by TB0ne View Post
Since your customers are using Red Hat enterprise, have they checked the Red Hat knowledebase for details, or called Red Hat??

The 'problem' doesn't exist...there is no problem in what you described, and if you read the man pages on kill, and looked up what the different signals mean, you'd see why. The "-15" tells the process to stop what its doing, and end itself. If the process is in the middle of something, it will complete whatever operation it's performing, then terminate. The "-9" doesn't care....it ends right then, maybe with corrupting/losing data, maybe not. So depending on what tomcat is doing, it'll either wait or not.

Thank you for your reply !
But customer is not agreeing to accept that there is no issue in script. They want to know why sometimes it just keeps running & doesn't do anything. Is there any way to troubleshoot it further to find out the reason?
Also, what is to be checked in RedHat knowledgebase?
Reg,
Bhakti
 
Old 03-15-2013, 07:50 AM   #4
BhaktiK
LQ Newbie
 
Registered: Mar 2013
Posts: 3

Original Poster
Rep: Reputation: Disabled
here is part of the script:
if [ ! -z "$CATALINA_PID" ]; then
if [ -s "$CATALINA_PID" ]; then
if [ -f "$CATALINA_PID" ]; then
kill -15 `cat "$CATALINA_PID"` >/dev/null 2>&1
if [ $? -gt 0 ]; then
echo "PID file found but no matching process was found. Stop aborted."
exit 1
fi
else
echo "\$CATALINA_PID was set but the specified file does not exist. Is Tomcat running? Stop aborted."
exit 1
fi
else
echo "PID file is empty and has been ignored."
fi
fi

"$_RUNJAVA" $JAVA_OPTS \
-Djava.endorsed.dirs="$JAVA_ENDORSED_DIRS" -classpath "$CLASSPATH" \
-Dcatalina.base="$CATALINA_BASE" \
-Dcatalina.home="$CATALINA_HOME" \
-Djava.io.tmpdir="$CATALINA_TMPDIR" \
org.apache.catalina.startup.Bootstrap "$@" stop

if [ ! -z "$CATALINA_PID" ]; then
if [ -f "$CATALINA_PID" ]; then
while [ $SLEEP -ge 0 ]; do
kill -15 `cat "$CATALINA_PID"` >/dev/null 2>&1
if [ $? -gt 0 ]; then
rm -f "$CATALINA_PID" >/dev/null 2>&1
if [ $? != 0 ]; then
if [ -w "$CATALINA_PID" ]; then
cat /dev/null > "$CATALINA_PID"
else
echo "Tomcat stopped but the PID file could not be removed or cleared."
fi
fi
break
fi
if [ $SLEEP -gt 0 ]; then
sleep 1
fi
if [ $SLEEP -eq 0 ]; then
if [ $FORCE -eq 0 ]; then
echo "Tomcat did not stop in time. PID file was not removed."
fi
fi
SLEEP=`expr $SLEEP - 1 `
done
fi
fi

if [ $FORCE -eq 1 ]; then
if [ -z "$CATALINA_PID" ]; then
echo "Kill failed: \$CATALINA_PID not set"
else
if [ -f "$CATALINA_PID" ]; then
PID=`cat "$CATALINA_PID"`
echo "Killing Tomcat with the PID: $PID"
kill -9 $PID
rm -f "$CATALINA_PID" >/dev/null 2>&1
if [ $? != 0 ]; then
echo "Tomcat was killed but the PID file could not be removed."
fi
fi
fi
fi
 
Old 03-15-2013, 10:38 AM   #5
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 22,090

Rep: Reputation: 5901Reputation: 5901Reputation: 5901Reputation: 5901Reputation: 5901Reputation: 5901Reputation: 5901Reputation: 5901Reputation: 5901Reputation: 5901Reputation: 5901
Quote:
Originally Posted by BhaktiK View Post
Thank you for your reply !
But customer is not agreeing to accept that there is no issue in script. They want to know why sometimes it just keeps running & doesn't do anything. Is there any way to troubleshoot it further to find out the reason?
Doesn't matter whether the customer agrees or not....that's just the way it is. Again, you need to read up on the different kill signals. A "-15" will behave differently than a "-9". If you don't like it, then change the script to issue a "-9", and hope the data doesn't get corrupted. Not anything else you can do. If you're doing work for this customer, then you should also do research on the problem...so again, read the man pages on kill, and look up the different kill signals and what they do/how they're interpreted.
Quote:
Also, what is to be checked in RedHat knowledgebase?
Whatever you'd like...there are tomcat related articles, kill related articles, and (since you're PAYING for RHEL, right??), you can call their tech support, and they can walk you through things and explain them.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How do you stop or kill a shell script from working? TrollingForest Programming 3 11-21-2012 08:39 AM
[SOLVED] How to stop tomcat 6.0 call_krushna Linux - Software 2 04-17-2012 09:11 AM
USB keyboard & mouse stop working intermittently on Linux Mint 12 boot macked Linux - Hardware 1 01-17-2012 05:24 AM
My server stop working stefane321 Linux - Server 5 08-03-2007 07:54 AM
Iptables firewall script stop working occassionally Niceman2005 Linux - Security 9 02-16-2007 01:35 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 02:17 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration