I'm wondering about the SSH -t option.

When I try to start a Tomcat server like this:

ssh user@example.com -t '~/tomcat/bin/startup.sh'

then Tomcat will not be started, eventhough the startup script is running through. Without the -t option, it works.

From my understanding, this is because once the startup script finishes, the connection is closed, and therefore all background processes that have been started by the script cease to exist.

Why is this the case? I'm not too familiar with shell sessions and jobs/processes.

Is there any way to bring Tomcat up with using the -t option? (Unfortunately I'm forced to use it because of Ansible).

  • The manual page explains what the -t switch does. What errors you see? What does not work? – Jakuje Feb 17 '17 at 15:07
  • no errors. the script is executed, but tomcat does not start. as i said above, all started processes seem to terminate once the startup script has finished. this of course prohibits tomcat to run. the man page doesnt give me any clue why this is the case. – Philipp Murry Feb 17 '17 at 15:19

With Ansible you can start tomcat service without calling the script directly.

Ex: tomcat service handler has this definition roles/tomcat/handler/main.yml

- name: restart tomcat
  service: name=tomcat state=restarted

The actual tomcat service start task at roles/tomcat/tasks/main.yml

- name: Configure Tomcat users
  template: src=tomcat-users.xml dest=/usr/share/tomcat/conf/
  notify: restart tomcat

- name: Start Tomcat
  service: name=tomcat state=started enabled=yes

If you want to launch you own script which starts any arbitrary service which is not part of any service monitoring system, the use of supervisor program helps to overcome this issue.

please refer to this for more information on 'beneifit on not allocating tty to ssh' https://serverfault.com/questions/593399/what-is-the-benefit-of-not-allocating-a-terminal-in-ssh

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.