Hi.

I have not followe3d this thread since the beginning, but

The standard tomcat distribution comes with a series of shell scripts in the "bin" directory, which do just that : start or stop tomcat. They are conveniently called "startup.sh" and "shutdown.sh". You could get inspiration from those.

Since you are talking about bash, it is to be presumed that you are on a Linux 
system.
If this Linux system has a package management system, it is very likely that there is a tomcat package available. Such tomcat packages come with startup and stop scripts for tomcat, which make it easy to start/stop tomcat via a shell command.

Furthermore, look at the on-line documentation. In http://tomcat.apache.org/tomcat-9.0-doc/config/server.html#Common_Attributes, you will find the "shutdown" attribute and its explanation. It basically means that if you open a TCP/IP socket to the given port (which you can do with bash), and send the indicated string on that connection, tomcat will initiate a shutdown.

And that's in fact what the standard shutdown.sh does, though using a roundabout way : it starts another java jvm instance which runs another temporary instance of tomcat, which just does one thing : send this shutdown string to the appropriate (main instance of tomcat's) shutdown port (and then it shuts itself down).

So it looks like there are a lot of ways to achieve what you want, and you only need to pick the right one for you.


On 28.06.2018 20:13, Luis Rodríguez Fernández wrote:
Hello Danesh

Perhaps you could look for any of your tomcat connector ports, ask for the
process that is listening and kill it:

$ ppid=`lsof -i:8080 -Fp | grep p`
$ pid=`echo ${ppid#p*}`
$ kill $pid

Probably you can find something more elegant but the idea could be this
one...

Hope it helps,

Luis


2018-06-27 17:02 GMT+02:00 Leon Rosenberg <rosenberg.l...@gmail.com>:

use -force option
bin/shutdown.sh -force

regards
Leon

On Wed, Jun 27, 2018 at 5:51 PM dhanesh1212121212 <dhanesh1...@gmail.com>
wrote:

Hi All,

Trying to stop and start tomcat in production using bash script for war
deployment.

If tomcat not stopped properly then how we can kill the correct process
and
make sure it's stopped correctly.

Regards,
Dhanesh M.







---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org

Reply via email to