Tomcat Autostart Linux
I use the following to autostart Tomcat on Linux. After editing the TOMCAT_PATH value put the script inside of \etc\rc.d\init.d as a file named tomcat.
Then enter the following command to add it to your startup.
/sbin/chkconfig --add --level 345 tomcat
Note. Set TOMCAT_PATH= to the location of your installed Tomcat's bin directory.
#!/bin/sh
# description: Tomcat start/stop script
# chkconfig: 2345 98 02
JAVA_HOME=/opt/jdk
PATH=${JAVA_HOME}/bin:${PATH}
if [ -z $JAVA_HOME ]
then
JAVA_HOME=/opt/jdk
PATH=${JAVA_HOME}/bin:${PATH}
export JAVA_HOME PATH
echo "Set JAVA_HOME to $JAVA_HOME"
fi
TOMCAT_PATH=ENTER_YOUR_TOMCAT_BIN_DIRECTORY_HERE
TOMCAT_START=$TOMCAT_PATH/startup.sh
TOMCAT_STOP=$TOMCAT_PATH/shutdown.sh
export JAVA_HOME PATH
start()
{
if [ -x ${TOMCAT_START} ]; then
echo "Starting tomcat server???"
${TOMCAT_START} &
else
echo "Cannot start tomcat server"
fi
}
stop()
{
if [ -x ${TOMCAT_STOP} ]; then
echo "Stopping tomcat server???"
${TOMCAT_STOP} &
else
echo "Cannot stop tomcat server"
fi
}
restart()
{
stop
sleep 10
start
}
status()
{
echo "No status available for tomcat server"
}
case "$1" in
'start')
start
;;
'stop')
stop
;;
'restart')
restart
;;
'status')
status
;;
*)
echo "Please supply an argument [start|stop|restart]"
esac
