Bash Shell Script for Apache Tomcat Start and Stop

Here is the bash script in Linux for Start, Stop & Restart of Apache Tomcat server.

shell script

Please follow the article for Installation of Apache Tomcat in Linux and If Java is not Installed,

Kindly Install Java in Linux using this article –
How to Install Java JDK in Linux


Copy and Paste the below shell script using Vi text editor.

# description: Script to Start Stop Restart Tomcat
export JAVA_HOME
export PATH
JAVA_OPTS="-Xms2048m -Xmx8192m -XX:MaxPermSize=512m
export JAVA_OPTS
case $1 in
/bin/su -p -s /bin/sh tomcat $TOMCAT_HOME/

/bin/su -p -s /bin/sh tomcat $TOMCAT_HOME/
/bin/su -p -s /bin/sh tomcat $TOMCAT_HOME/
/bin/su -p -s /bin/sh tomcat $TOMCAT_HOME/
exit 0

we need to set the JAVA_HOME & TOMCAT_HOME path according to our configurations. For example, in the above script, JAVA_HOME is /usr/java/default And TOMCAT_HOME is /opt/tomcat-8/bin

Save the file in the /etc/init.d/ directory

# cp /etc/init.d/
# chmod +x

Now to start the script,

# ./ start

For stop,

# ./ stop

To restart

># ./ restart

We have seen about the Shell script for tomcat start & stop in Linux.[adAuto]

Do you know How to 

Kindly share your thoughts & comments in the below form,

Leave a Reply