Wednesday, May 7, 2014

Automated tomcat start up on server reboot

Automated start up on server reboot

Create a new tomcat user using the following command:
adduser tomcat

Create the following file /etc/init.d/tomcat:
# tomcat       
# chkconfig:
# description: Start up the Tomcat servlet engine.

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


case "$1" in
        if [ -f $CATALINA_HOME/bin/ ];
            echo $"Starting Tomcat"
            /bin/su tomcat $CATALINA_HOME/bin/
        if [ -f $CATALINA_HOME/bin/ ];
            echo $"Stopping Tomcat"
            /bin/su tomcat $CATALINA_HOME/bin/
        echo $"Usage: $0 {start|stop}"
        exit 1

exit $RETVAL

Edit the file and change CATALINE_HOME to the location of where tomcat is found.

Grant execution write of the new file using the following command:
chmod 755 /etc/init.d/tomcat

Reassign the owner of the tomcat folder and all subfolders to the tomcat user:
chown tomcat:tomcat –R /usr/local/apache-tomcat-7.0.52

To start up on server reboot:
ln –s ../init.d/tomcat S71tomcat

No comments:

Post a Comment