PhixFlow Help

Unix Scripts

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.

Tomcat login scripts

Script: .bashrc

Install in the tomcat home directory

# .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

Change the settings for:

  • JAVA_HOME

according to your setup.

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

# 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
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
export TOMCAT_HOME=/opt/tomcat
export PATH=$PATH:$TOMCAT_HOME/bin

For oracle users

These settings maybe useful if you have the oracle server or oracle client installed on the application server.

Add settings to .bash_profile for:

  • ORACLE_HOME
  • ORACLE_SID

according to your setup. For example:

 # oracle
export ORACLE_HOME=/u01/app/oracle/product/11.1.0/db_1
export ORACLE_SID=test1
export PATH=$PATH:$ORACLE_HOME/bin

 

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

 

 #!/bin/bash
#
# Run level script to start tomcat
USER="tomcat"
DIR="/opt/tomcat"
case "$1" in
        start)
        echo  "*** Starting Tomcat *** "
        su - $USER -c "cd $DIR; startup.sh"
        ;;
        stop)
        echo  "*** Stopping Tomcat *** "
        su - $USER -c "shutdown.sh"
        ;;
        restart)
        $0 stop
        $0 start
        ;;
        *)
        echo $"Usage: $0 {start|stop|restart}"
        exit 1
esac
exit 0

Please let us know if we could improve this page feedback@phixflow.com