1

Can any one share their Tomcat startup script I am looking for a tomcat start up script on a Ubuntu machine. My Ubuntu is 10.04 server. The tomcat is 5.5.30.

It is in /opt/apache-tomcat-5.5.31

I tried a script

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

# Source function library.
. /lib/lsb/init-functions


RETVAL=$?
CATALINA_HOME="/opt/apache-tomcat-5.5.31"

case "$1" in
start)
if [ -f $CATALINA_HOME/bin/startup.sh ];
then
echo $"Starting Tomcat"
/opt/apache-tomcat-5.5.31/bin/startup.sh

fi
;;
stop)
if [ -f $CATALINA_HOME/bin/shutdown.sh ];
then
echo $"Stopping Tomcat"
/opt/apache-tomcat-5.5.31/bin/shutdown.sh
fi
;;
*)
echo $"Usage: $0 {start|stop}"
exit 1
;;
esac
exit $RETVAL 

but it did not worked after a reboot. But the same script works if I do /etc/init.d/tomcat start or /etc/init.d/tomcat stop I have done
update-rc.d tomcat defaults
as it is a Ubuntu server but on reboot all of this fails to work.

Registered User
  • 1,453
  • 5
  • 18
  • 37

2 Answers2

2

For some weired reason the script was not working after reboot and it turns out that Tomcat needs JAVA_HOME variable to be able to start itself.This variable I had defined in .bashrc but this script was still not able to work.So when I defined JAVA_HOME in the above script also then it did worked.

Registered User
  • 1,453
  • 5
  • 18
  • 37
1

To start a service on boot, the init script should be in the directory /etc/init.d, but the real start and stop are triggered by the symbolic links in the directories /etc/rcX.d (X being the runlevel number).

On Debian derivatives like Ubuntu, when your init script is in /etc/init.d, you can use update-rc.d to create the links, for example if your init script is called tomcat :

update-rc.d tomcat default
jon_d
  • 693
  • 4
  • 7