This question already has an answer here:

i have an ubuntu-server box to which i connect via ssh.

now when i start a service (in this case teamcity) i would like to keep it running after the ssh session ends.

right now the service stops as soon as i disconnect.

i am starting the service using:

sudo service teamcity start

and the service script looks like this:

#! /bin/sh
# /etc/init.d/teamcity

# Carry out specific functions when asked to by the system
case "$1" in
    echo "Starting script teamcity "
    /home/m/TeamCity/bin/runAll.sh start
    echo "Stopping script teamcity"
    /home/m/TeamCity/bin/runAll.sh stop
    echo "Usage: /etc/init.d/teamcity {start|stop}"
    exit 1

exit 0

marked as duplicate by Gilles bash Dec 14 '14 at 21:17

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • you should use screen google it for functions etc. – user94896 Dec 14 '14 at 12:38

You probably need to add a nohup to your startup scripts. It sounds like your processes are terminating when your session ends. You might also want to look at how standard daemons are started with ubuntu, and rewrite the init script your script is referencing.

  • for a normal process i would use nohup. but as for services, i thought the main purpose is to keep them running after logout, i dont see why nohup is necessary. – clamp Dec 15 '14 at 9:36
  • The TeamCity startup script you are using isn't doing anything to catch the HUP signal being sent when your SSH session closes and the controlling terminal closes. In an ideal world, the people who wrote the startup scripts would have thought of that, but they didn't. – jsbillings Dec 17 '14 at 1:52

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