-1

How to write the shell script for to stop the tomcat.

tomcat version -  tomcat9
  environment  -  Linux
   OS          -  centos7
Du-Lacoste
  • 11,530
  • 2
  • 71
  • 51
madhuri
  • 103
  • 2
  • 11

3 Answers3

0

The scripts located in the Tomcat directory are the most barebones ways of starting the server. To stop the Tomcat server change active directory to the tomcat root and execute

./catalina.sh stop

I recommend reading this article by O'Reilly to better understand how tomcat works:
Starting, Stopping, and Restarting Tomcat

neau
  • 48
  • 8
0

You can create basic shell script and add one of the following commands mentioned below. If need to automate that can be done by CronScheduler built in Linux tool.

There are two ways this can be done in Linux and Windows.

Linux:

./catalina.sh stop

Passing "stop" argument for catalina.sh --> stops the Tomcat in the background. Since in background no issues closing down the terminal. The logs need to be viewed as below: tail -f $CATALINA_HOME/logs/catalina.out

./shutdown.sh 

The last way is firing the shutdown.sh to stop your Tomcat server. If you Vi the script you can see it calls catalina.sh script passing stop as the argument. This will be running in background as well.

Windows:

shutdown.bat // stop tomcat server
Du-Lacoste
  • 11,530
  • 2
  • 71
  • 51
-1

Create a file and write the following lines of code:

#!/bin/bash
systemctl stop tomcat

execute the bash script: bash fileName.sh

sgeorgiou
  • 59
  • 10
  • Then try starting it and stopping it using the following commands in the bash script: ./catalina.sh start ./catalina.sh stop – sgeorgiou Apr 23 '19 at 13:42