Tuesday, April 1, 2014

Tomcat : Enable auto startup Tomcat service in Centos 6

1. Create a file named tomcat in your /etc/init.d directory
#cd /etc/init.d
#touch tomcat

2. Copy and paste script on /etc/init.d/tomcat
#!/bin/bash

TOMCAT_HOME=/opt/tomcat/bin
START_TOMCAT=/opt/tomcat/bin/startup.sh
STOP_TOMCAT=/opt/tomcat/bin/shutdown.sh

start() {
echo -n "Starting tomcat8: "
cd $TOMCAT_HOME
${START_TOMCAT}
echo "done."
}

stop() {
echo -n "Shutting down tomcat8: "
cd $TOMCAT_HOME
${STOP_TOMCAT}
echo "done."
}

case "$1" in

start)
start
;;

stop)
stop
;;

restart)
stop
sleep 10
start
;;

*)
echo "Usage: $0 {start|stop|restart}"

esac
exit 0

3. Change tomcat file permission
#chmod 755 tomcat

4. Run chkconfig command to add the script to the startup services
#chkconfig  tomcat on

5.Verify tomcat service
#service tomcat start
#service tomcat stop

source :

Related Posts:

0 comments:

Post a Comment