Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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

2 Answers 2

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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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