Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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.

share|improve this question
add comment

2 Answers

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
share|improve this answer
add comment
up vote 1 down vote accepted

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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.