Showing posts with label Start tomcat at the boot time. Show all posts
Showing posts with label Start tomcat at the boot time. Show all posts

Thursday, July 11, 2013

Tomcat start up script.


1.Ensure there is tomcat user and it has read, write permission to the $CATALINA_HOME/conf and $CATALINA_HOME/logs directories.

2. Also make sure that you have set $JAVA_HOME.

3. Ensure that the tomcat processes are ran by the tomcat user.

4. Save the following scripts as /etc/init.d/tomcat. They will automatically be read and run at boot time.

Check the log files if it does not start properly.

Make a soft link to it from /etc/rc5.d such as:

cd /etc/rc5.d
sudo ln -s /etc//init.d/tomcat S71tomcat


/etc/init.d/tomcat

#!/bin/bash
#
# tomcat      
#
# chkconfig:
# description: Start up the Tomcat servlet engine.

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


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

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

exit $RETVAL


Inspired from http://www.raibledesigns.com/