If you want Tomcat to start automatically on boot then you need to set it up as a service. To do this you need to copy the code below and save it as a file called tomcat in the folder /etc/init.d:
# Jakarta Tomcat server
#
# chkconfig: 345 91 10
# description: Starts and stops the Tomcat daemon.
#
# Source function library.
. /etc/rc.d/init.d/functions
# Get config.
. /etc/sysconfig/network
# Check that networking is up.
[ "${NETWORKING}" = "no" ] && exit 0
tomcat=/usr/share/tomcat
startup=$tomcat/bin/startup.sh
shutdown=$tomcat/bin/shutdown.sh
export JAVA_HOME=/usr/java/jre1.5.0_12/
export CATALINA_HOME=/usr/share/tomcat
start(){
echo -n $”Starting Tomcat service: “
$startup
RETVAL=$?
echo
}
stop(){
action $”Stopping Tomcat service: ” $shutdown
RETVAL=$?
echo
}
status(){
numproc=`ps -ef | grep catalina | grep -v “grep catalina” | wc -l`
if [ $numproc -gt 0 ]; then
echo “Tomcat is running…”
else
echo “Tomcat is stopped…”
fi
}
restart(){
stop
sleep 5
start
}
# See how we were called.
case “$1″ in
start)
start
;;
stop)
stop
;;
status)
status
;;
restart)
restart
;;
*)
echo $”Usage: $0 {start|stop|status|restart}”
exit 1
esac
exit 0
You may have to change the value for tomcat and JAVA_HOME if Tomcat and your JDK are in different locations to mine. You then need to make the file executable with the command:
And finally you need to set it to start at boot with the command:
You now have a working Tomcat install that will start it self at boot time. You can also interact with it using the service command to start, stop, restart and see the status of the service at any time. E.g.
sudo service tomcat satus
sudo service tomcat stop
[Adapted from http://www.bartbusschots.ie/blog/?p=240]