Reputation: 391
I am trying to start tomcat by invoking the ./start
script under the tomcat_user
dir. It works when I log into server directly and invoke /home/tomcat_user/start
, but it doesn't if I use this from a different host:
ssh user@server '/home/tomcat_user/start'
I believe it has something to do with the files that get executed at the beginning (maybe like environment variables and such) being different when logging into remote server directly vs doing from within ssh like above.
Is there a way to achieve the same exact behavior for logging directly to server and executing a remote command using ssh like above to automate the logging part?
Thank you very much.
OK, after reading about nohup, while it's a great explanation, I am afraid it's not the problem here, since tomcat doesn't seem to get started to begin with (and not getting killed when the ssh is over (I actually do a sleep 500 at the end of the command passed to ssh, but still tomcat wouldn't start)). The more I think about it, the more I think it's env variables, but I don't exactly know what. There is no .bashrc, or .profile in tomcat_user home directory and I am not too familiar with them.
My reason for saying it's env variables is that when I login directly and start tomcat the console writes all the env varialbes (such as TOMCAT_HOME, CATALINA_HOME, JAVA_HOME, etc), and then it says "Starting tomcat", but when I do it via ssh, none of the env variables gets printed. I only get "Starting tomcat". I guess I can set those variables in my ssh script easily enough, but I am not sure if those are the only variables, so that's why I was wondering if I can mimic the same exact behavior of logging directly, within my script passed to ssh.
Still confused and not sure how to proceed. Help is appreciated! Thanks,
When trying to start tomcat with nohup start& seems like it can't proceed, as it prints out the usage (not sure how to interpret the usage and how to start tomcat. Am I supposed to use the start differently to start tomcat?). Here is the content of nohup.out:
Starting tomcat_user...
Using CATALINA_BASE: /prod/web/edmsserv/current
Using CATALINA_HOME: /opt/tomcat-6.0.18
Using CATALINA_TMPDIR: /prod/web/edmsserv/current/temp
Using CATALINA_OPTS: -DappName=edmsserv -server -Xmx768m -XX:PermSize=256m -XX:MaxPermSize=256m -DEXPD_APPL_DOMAIN=QA -XX:+UseG1GC -XX:+UnlockExperimentalVMOptions -XX:-UseStringCache -XX:+AggressiveOpts -XX:MaxInlineSize=75 -XX:FreqInlineSize=700 -XX:InterpreterProfilePercentage=10 -XX:CompileThreshold=20000 -XX:OnStackReplacePercentage=80 -XX:ReservedCodeCacheSize=128m -XX:AllocatePrefetchStyle=2 -XX:AllocatePrefetchDistance=896 -Dsun.rmi.dgc.client.gcInterval=28800000 -Dsun.rmi.dgc.server.gcInterval=28800000 -verbose:gc -XX:+PrintGCDetails -XX:+PrintGCTimeStamps -Dsun.net.inetaddr.ttl=0 -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.authenticate=true -Dcom.sun.management.jmxremote.port=26236 -Dcom.sun.management.jmxremote.access.file=/export/home/edmsserv/.jmxremote.access -Dcom.sun.management.jmxremote.password.file=/export/home/edmsserv/.jmxremote.password -Dcom.sun.management.jmxremote.ssl=false
Using CLASSPATH: :/opt/tomcat-6.0.18/bin/bootstrap.jar:/export/home/db2inst3/sqllib/java/db2jcc.jar:/export/home/db2inst3/sqllib/java/sqlj.zip:/export/home/db2inst3/sqllib/function:/export/home/db2inst3/sqllib/java/db2jcc_license_cu.jar:.:
Using JRE_HOME: /opt/java-1.6.0_26
usage: pargs [-acexF] { pid | core } ...
(show process arguments and environment)
-a: show process arguments (default)
-c: interpret characters as 7-bit ascii regardless of locale
-e: show environment variables
-l: display arguments as command line
-x: show aux vector entries
-F: force grabbing of the target process
Upvotes: 1
Views: 1463
Reputation: 6120
Can you try the following command instead ?
ssh user@server 'cd /home/tomcat_user ; nohup /home/tomcat_user/start &'
This will create a nohup.out file under /home/tomcat_user. Ideally this command should solve the problem ; if not, the nohup.out will provide details regarding why it failed.
If I recall correctly, ssh should initialize the env variables. If you think environment variables are causing an issue, issue the following command to run the startup script (assuming you are using bash shell).
ssh user@server 'cd /home/tomcat_user ; . ./bash_profile ; nohup /home/tomcat_user/start &'
Upvotes: 1