Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

The following scripts are examples which could be set up to run when the tomcat user logs in. In some installations these scripts may be run without change, however the final scripts should be checked against the latest recommendations from the Apache group.

Anchor
tomcatLoginScripts
tomcatLoginScripts
Tomcat login scripts

Script: .bashrc

Install in the tomcat home directory

Code Block
languagebash
# .bashrc

...


# Source global definitions

...


if [ -f /etc/bashrc ];

...

 then
     . /etc/bashrc

...


fi

...


# User specific aliases and functions

...


# .bash_profile

Script: .bash_profile

Install in the tomcat home directory

...

Also change memory configuration (especially the maximum memory –Xmx) according to the memory on your server and server tuning.

# Get the aliases and functions

...

Code Block
languagebash
 # Get the aliases and functions
if [ -f ~/.bashrc ];

...

 then
     . ~/.bashrc

...


fi

...


# User specific environment and startup programs

...


# base settings

...


export PATH=$PATH:$HOME/bin

...

 

# java

...




# java
export JAVA_HOME=/opt/java/jre6

...


export PATH=$PATH:$JAVA_HOME/bin

...

 

...




# JAVA_OPTS standard settings

...


export JAVA_OPTS='-Xms5000m -Xmx15000m -Xss1024k -verbose:gc -Djava.awt.headless=true'

...

 

...




# JAVA_OPTS remove debug settings

...


#
 export JAVA_OPTS='-Xms5000m -Xmx15000m -Xss1024k -verbose:gc 
-Djava.awt.headless=true -Xdebug 
-Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=n'

...

 

...




# JAVA_OPTS profiler settings

...


# export JAVA_OPTS="-Xms5000m -Xmx15000m -Xss512k -verbose:gc $JPROFILER_OPTS"

...

 

# tomcat

...




# tomcat
export TOMCAT_HOME=/opt/tomcat

...


export PATH=$PATH:$TOMCAT_HOME/bin

Anchor
oracleLoginScripts
oracleLoginScripts

...

Oracle login scripts

Add settings to .bash_profile for:

  • ORACLE_HOME
  • ORACLE_SID

according to your setup. For example:

# oracle

...

 

Code Block
languagebash
 # oracle
export ORACLE_HOME=/u01/app/oracle/product/11.1.0/db_1

...


export ORACLE_SID=test1

...


export PATH=$PATH:$ORACLE_HOME/bin

 

Anchor
tomcatServiceScripts
tomcatServiceScripts
Tomcat service scripts

Script: tomcat

Install in /etc/rc.d/init.d and create a soft link in (for example) /etc/rc3.d to force startup on login

...

 

Code Block
languagebash
 #!/bin/bash

...


#

...


# Run level script to start tomcat

...


USER="tomcat"

...


DIR="/opt/tomcat"

...


case "$1"

...

        start)

...

 in
        start)
        echo  "*** Starting Tomcat ***

...

        su - $USER -c "cd $DIR; startup.sh"

        ;;

        stop)

...

 "
        su - $USER -c "cd $DIR; startup.sh"
        ;;
        stop)
        echo  "*** Stopping Tomcat ***

...

 "
        su - $USER -c "shutdown.sh"

...

        ;;

        restart)

        $0 stop

        $0 start

        ;;

        *)

...


        ;;
        restart)
        $0 stop
        $0 start
        ;;
        *)
        echo $"Usage: $0 {start|stop|restart}"

...

        exit 1

esac

...


        exit 1
esac
exit 0