Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

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

If I run code (e.g. an executable) on a Linux command-line interface and then close the interface, what happens? Does the executable keep running in the background? What if it requires user-input? Can I "return to it" (e.g. to supply it with user input) during a later session?

Does this behavior change if the command-line interface is accessed remotely (e.g. via SSH)?

share|improve this question
up vote 4 down vote accepted

Unless you ran said command in a program like screen or tmux; or you have backgrounded (bg) and disowned (disown) said program, it will be killed when it's parent shell dies (and closing a terminal emulator's window will kill the shell)

share|improve this answer

Variations of this question have been asked before. You can find them if you search on nohup, screen or tmux.

But briefly:
When you close the connection of the network interface goes offline the program you are running gets told that you disconnected (with a SIGHUP) and terminates.

If you want them to keep running despite this you need to tell them to ignore this hangup signal, which you can do by prepending the nohup command.

A much more comfortable method is to run screen or tmux which will keep your state is it was until you reconnect. (And which can do much much more).

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .