Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?


share|improve this question

marked as duplicate by Gilles, Michael Mrozek Jan 7 '11 at 22:20

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.

up vote 2 down vote accepted

Start it in a screen session.


Now start the process:


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
share|improve this answer

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.

share|improve this answer
How do I do that? – Adam Jan 7 '11 at 21:56

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