Tomcat Shell Script

This information is now maintained on my wiki http://www.mikepalmer.net/wiki/ApacheTomcatHowto.

Here is a tomcat start script I have written for this under Fedora/Redhat. You can download the formatted script here or you can make a file in /etc/init.d/ named tomcat and inject the information below:
#!/bin/bash
#
# apache
#
# chkconfig:
# description:  Start up the Tomcat servlet engine.

# Source function library.
. /etc/init.d/functions


RETVAL=$?
TOMCATHOME="/usr/local/tomcat"

case "$1" in
 start)
        if [ -f $TOMCATHOME/bin/startup.sh ];
          then
            echo $"Starting Tomcat"
            /bin/su - tomcat -c $TOMCATHOME/bin/startup.sh
        fi
        ;;
 stop)
        if [ -f $TOMCATHOME/bin/shutdown.sh ];
          then
            echo $"Stopping Tomcat"
            /bin/su - tomcat -c $TOMCATHOME/bin/shutdown.sh
        fi
        ;;
 *)
        echo $"Usage: $0 {start|stop}"
        exit 1
        ;;
esac

exit $RETVAL

Make sure the shell script is executable by running;

chmod a+x /etc/init.d/tomcat
Here is a tomcat init.d script I have written for Debian
#!/bin/sh
# Tomcat Servlet Engine

case "$1" in
 'start')
	if [ -f /usr/local/tomcat/bin/startup.sh ];
	  then
	    echo $"Starting Tomcat"
	    /bin/su - tomcat -c /usr/local/tomcat/bin/startup.sh
	fi
	;;
 'stop')
	if [ -f /usr/local/tomcat/bin/shutdown.sh ];
	  then
	  echo $"Stopping Tomcat"
	  /bin/su - tomcat -c /usr/local/tomcat/bin/shutdown.sh
	fi
	;;
 *)
	echo "Usage: $0 { start | stop }"
	;;
esac
exit 0

Back to mod_jk2 Main Continue to Final Configuration