I would like to write shell script to start and stop tomcat server.For stopping the tomcat I am using this command \"./bin/shudown.sh\" or \"./bin/catalina.sh stop\". This is no
./bin/catalina.sh
should support this. If you run that command without any options, it will print out its usage, which describes:
stop n -force Stop Catalina, wait up to n seconds and then use kill -KILL if still running
In order to make this work, you need to set the environment variable CATALINA_PID
to a file name that will be used to hold the Tomcat process ID. To start Tomcat, use:
export CATALINA_PID=/tmp/catalina.pid
./bin/catalina.sh start
And then to stop it:
export CATALINA_PID=/tmp/catalina.pid
./bin/catalina.sh stop 600 -force
This will try to stop it, wait for 5 minutes, then kill it if necessary. Note that this will run in the foreground by default (locking up the terminal instance); use a trailing &
to run the command in the background.
You can use: pkill -9 tomcatServiceName or killall -9 tomcatServiceName.