LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Slackware (https://www.linuxquestions.org/questions/slackware-14/)
-   -   how to get Tomcat to run on startup? (https://www.linuxquestions.org/questions/slackware-14/how-to-get-tomcat-to-run-on-startup-454928/)

TrevorS 06-15-2006 12:52 AM

how to get Tomcat to run on startup?
 
Thank you to all of you who helped me get Slackware installed and running.

I just installed Apache Tomcat, and it runs fine, but I can't seem to get it to run on startup (boot up) of the machine. What else do I need to do?

Just like I did successfully with MySQL when I installed it, I added the following to /etc/rc.d/rc.M (after the code which launches Apache):

if [ -x /etc/rc.d/rc.tomcat ]' then
. /etc/rc.d/rc.tomcat start
fi

Manually, I created the rc.tomcat (owned by root:root with -rwxr-xr-x permissions) and it contains:

case "$1" in
'start')
/apache-tomcat-5.5.17/bin/startup.sh
;;
'stop')
/apache-tomcat-5.5.17/bin/shutdown.sh
;;
'restart')
/apache-tomcat-5.5.17/bin/shutdown.sh
sleep 3
/apache-tomcat-5.5.17/bin/startup.sh
;;
*)
echo "usage $0 start|stop|restart"
esac

Now, if I login as root and type "/etc/rc.d/rc.tomcat start" from the command line, Tomcat starts just fine. So I guess my script is okay. If I copy/paste the code piece inside rc.M into a temporary file and execute it, Tomcat starts fine. So why doesn't Tomcat startup automatically when I first boot the machine? What else do I need to do?

Is there a log file somewhere that I can look at? Nothing in /apache-tomcat-5.5.17/logs seems to be helpful.

TrevorS 06-15-2006 12:54 AM

typo
 
...don't worry, my script really does have the ; instead of the '

if [ -x /etc/rc.d/rc.tomcat ]; then

bathory 06-15-2006 01:54 AM

You should use:
Code:

export JAVA_HOME=/path/to/java
export CATALINA_HOME=/path/to/tomcat

before anthing else in your script, since those env. variables are not defined yet.

Regards

TrevorS 06-15-2006 08:26 AM

fixed!
 
That did it!

I had the export statements in /etc/profile, but I guess that must be read after /etc/rc.d/rc.M, because moving the export statements to rc.M just prior to calling /etc/rc.d/rc.tomcat did the trick.

Maybe this is basic stuff to you folks, but I don't know how I would hae figured it out as a newbie without you. Thanks!

Lee Barker 08-04-2006 12:51 AM

Hi,

I have installed Tomcat (following Marty Hall's excellent guide) and everything works fine.

My question is in relation to the startup.sh and catalina.sh files. Why do I need to be root user to start Tomcat? Is there a way to allow the local user to do this?

The only thing I've spotted is that the file tomcat-users.xml is root:root - all else is localuser:users.

So my problem is that I have to su - root each time I need to control the server.

Regards,
Lee.

gilead 08-04-2006 01:41 AM

I have a tomcat user and tomcat group and I just did chown -R tomcat:tomcat /usr/local/apache-tomcat-5.5.17 - then in my start up script I have:
Code:

/bin/su - tomcat -c /usr/local/bin/start-tomcat.sh
start-tomcat.sh has the environment variables I need and calls the Tomcat startup stuff.

Lee Barker 08-04-2006 02:15 AM

Thanks for this Steve.

I had created symbolic links to the startup/shutdown scripts and placed them in my home directory.

I also had chgrp/chown the tomcat installation directory in favour of my local user - so I thought that would work.

Does your tomcat user have (root like) higher privileges than a default user?

I must admit that I'm not too familiar with the su options and I guess I can substitute root for your tomcat on my machine (not recommended I know).

Regards,
Lee.

gilead 08-04-2006 02:56 PM

My tomcat user is a regular user, but for other users in the tomcat group I had to run the following so they could write to the Tomcat directories:
Code:

find /usr/local/apache-tomcat-5.5.17 -type d -exec chmod -c g+ws {} \;
That gave write permissions to the tomcat group to all Tomcat directories as well as making sure the group ownership of files stays at tomcat. My install is for dev/testing so I let the users write to config files, libs, etc. as well as the webapps directory. Nobody but the administrator has rights to the acceptance test and production boxes...

wanna13e 09-19-2006 10:24 PM

tomcat startup script
 
Hi all,

I got which i wrote for my tomcat version 5.0.27 using jsdk 1.4.2 to startup in /etc/init.d but i have some problem with it. Is there any kind soul who can me here. thanks amillion in advance.

Code:

#!/bin/bash
 #
 # Source function library.
. /etc/rc.d/init.d/functions

export JAVA_HOME=/opt/j2sdk
export CLASSPATH=.:/opt/j2sdk/lib/tools.jar:/opt/j2sdk/lib/rt.jar
export PATH=/opt/j2sdk/bin:/j2sdk/bin:$PATH

RETVAL=$?

JAVA_OPTS="-Xincgc -Xms64m -Xmx512m"
SITE_ROOT="/opt/tomcat"
SITES='ls ${SITE_ROOT}

  case "$1" in
    start)
        for x in ${SITES} 
          do
            CATALINA_BASE="${SITE_ROOT}/${x}/tomcat"
                if [ -f $CATALINA_BASE/bin/startup.sh];
                  then
                        echo "Starting Server: ${x}"
                        JAVA_OPTS="${JAVA_OPTS}"
                        $CATALINA_BASE/bin/startup.sh
                fi
                done
                ;;
                stop)
                  for x in ${SITES} 
                  do
                    CATALINA_BASE="${SITE_ROOT}/${x}/tomcat"
                        if [ -f $CATALINA_BASE/bin/shutdown.sh];
                          then
                                echo "Shutting down Server: ${x}"
                                $CATALINA_BASE/bin/shutdown.sh
                        fi
                  done
                  ;;
                  *)
                  echo $"Usage: $0 {start|stop}"
                  exit 1
                  ;;
                  esac
                  exit $RETVAL



All times are GMT -5. The time now is 08:01 AM.