Skip to content

Instantly share code, notes, and snippets.

@rodolfo42

rodolfo42/tomcat.sh

Last active May 13, 2020
Embed
What would you like to do?
Apache Tomcat 7 service init script
#!/bin/bash
### BEGIN INIT INFO
# Provides: tomcat
# Defalt-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Description: Apache Tomcat 7
### END INIT INFO
# base dir of tomcat installation #
CATALINA_HOME=/opt/tomcat/
# full path for file which will hold the PID #
# used by 'status' #
CATALINA_PID=/var/run/tomcat.pid
export CATALINA_PID
status=0
case $1 in
start)
sh $CATALINA_HOME/bin/startup.sh
;;
stop)
sh $CATALINA_HOME/bin/shutdown.sh
;;
restart)
sh $CATALINA_HOME/bin/shutdown.sh
sh $CATALINA_HOME/bin/startup.sh
;;
status)
if ! [ -z "$CATALINA_PID" ]; then
if [ -r $CATALINA_PID ]; then
pid=`cat "$CATALINA_PID"`
if ! [ -z $pid ]; then
echo "tomcat (pid $pid) is running..."
else
echo "tomcat is stopped"
fi
else
echo "tomcat is stopped"
fi
else
echo "No PID file found for tomcat..."
echo "(variable \$CATALINA_PID is not defined)"
status=1
fi
;;
esac
exit $status
@eldenis

This comment has been minimized.

Copy link

@eldenis eldenis commented May 13, 2020

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.