Ssh – starting tomcat remotely fails to start

sshtomcattomcat7

When I run my start command via ssh it tells me that its started but it is in fact not the case. Catalina logs does not seem to capture any events either. However stop and status works.

ssh -t SERVER1 'sudo /etc/init.d/tomcat7 start'
Starting tomcat
Using CATALINA_BASE:   /opt/tomcat
Using CATALINA_HOME:   /opt/tomcat
Using CATALINA_TMPDIR: /opt/tomcat/temp
Using JRE_HOME:        /usr/java/default
Using CLASSPATH:       /opt/tomcat/bin/bootstrap.jar:/opt/tomcat/bin/tomcat-juli.jar
Tomcat started.

When I run the command locally on the SERVER1 it starts successfully.

I'm a bit baffled by this behaviour. Any idea what the root cause might be?

Best Answer

So this turned out to be an issue when tty was enabled via the ssh -t option. The tomcat process only remained active as long as the tty session was active. I had modify the start up script by prefixing the start up command with nohup which fixed the issue.

nohup - run a command immune to hangups, with output to a non-tty