1

I must launch 2 instances of tomcat on a server and with the same user. I'm trying to set differents CATALINA_BASE when launching tomcat but this environment variable is not used.

That is the commands I use:

base0=/home/$INT/inst0
base1=/home/$INT/inst1
#...

su $INT -c "CATALINA_BASE=$base0;$cathome/bin/startup.sh"
su $INT -c "CATALINA_BASE=$base1;$cathome/bin/startup.sh"

and that is what I see in the console:

Using CATALINA_BASE:   /home/mci2/tomcat
Using CATALINA_HOME:   /home/mci2/tomcat
Using CATALINA_TMPDIR: /home/mci2/tomcat/temp

The catalina_home is ok but not the catalina_base.

Dit I miss something?

GaetanZ
  • 2,819
  • 3
  • 21
  • 20
  • Use CATALINA_HOME instead of CATALINA_BASE. – Satish Feb 01 '13 at 16:55
  • The running.txt file says : In CATALINA_BASE:* bin - Only the following files: * setenv.sh.... In CATALINA_HOME: * bin - Startup and shutdown scripts. My problem is that the CATALINA_BASE variable is not present when the startup.sh script is starting. – GaetanZ Feb 01 '13 at 17:01
  • CATALINA_HOME=/home/$INT/inst0 try this – Satish Feb 01 '13 at 17:23
  • Perhaps you need to `export CATALINA_BASE=` so that `startup.sh` actually inherits that environment variable? – twalberg Feb 01 '13 at 19:25
  • See this answer http://stackoverflow.com/questions/3090398/tomcat-catalina-base-and-catalina-home-variables – Marco Schoolenberg Jan 04 '17 at 16:44

2 Answers2

1

You should use single quotes:

su -c "var=Hello; echo $var"

vs

su -c 'var=Hello; echo $var' 

The shell interpretes the variables inside the double quotes, and having that you have not set the CATALINA_BASE for the env from which you execute su it replaces it with and empty string before actually executing the su.

SOFe
  • 7,867
  • 4
  • 33
  • 61
sasoiliev
  • 81
  • 4
0

If you are running multiple instances of Tomcat on a single host you should set CATALINA_BASE to be equal to the .../tomcat_instance1 or .../tomcat_instance2 directory as appropriate for each instance and the CATALINA_HOME environment variable to the common Tomcat installation whose files will be shared between the two instances. tomcat - CATALINA_BASE and CATALINA_HOME variables

Community
  • 1
  • 1