2

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
  start)
    echo "Starting script teamcity "
    /home/m/TeamCity/bin/runAll.sh start
    ;;
  stop)
    echo "Stopping script teamcity"
    /home/m/TeamCity/bin/runAll.sh stop
    ;;
  *)
    echo "Usage: /etc/init.d/teamcity {start|stop}"
    exit 1
    ;;
esac

exit 0
clamp
  • 1,663

1 Answers1

1

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.

jsbillings
  • 24,406
  • 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 09: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 01:52