2

Possible Duplicate:
Keep SSH Sessions running after disconnection.

I have a process which is basically a web-server, I start it during an SSH session. However, when I leave the session (by closing the PuTTY windows), it stops running and responding to requests. This is true even if I end the command with a &. With Apache, I don't have this problem, it comes with a stop, a start, and a restart script. I'd like to create something like that for this program.

How can I start a process, so that it will continue running even after I end the SSH session I started it in? Also how can I set it to restart itself if it stops for some reason?

Thanks!

Adam
  • 149
  • 6
  • possible duplicate of [Keep SSH Sessions running after disconnection.](http://unix.stackexchange.com/questions/479/keep-ssh-sessions-running-after-disconnection). Also near-dupes: [How can I close a terminal without killing the command running in it?](http://unix.stackexchange.com/questions/4004/how-can-i-close-a-terminal-without-killing-the-command-running-in-it) [Running continuous jobs remotely.](http://unix.stackexchange.com/questions/1037/running-continuous-jobs-remotely) – Gilles 'SO- stop being evil' Jan 07 '11 at 21:57

2 Answers2

2

Start it in a screen session.

screen

Now start the process:

myprocess

Then, detach the screen session with Ctrl+a d.

You can reattach to the screen session again by typing:

screen -r

If you have more sessions running you can list them with:

screen -ls
wag
  • 35,104
  • 11
  • 66
  • 51
1

You can make it a daemon (fork it twice or have it started by the system's init daemon) or for temporary stuff use screen.

Kevin Cantu
  • 3,774
  • 4
  • 18
  • 13