Keep program running after disconnect

Screen is a terminal multiplexer program available for Linux, MacOS, BSD and similar. Screen allows programs to continue running after a remote user disconnects. If a remote connection is lost unintentionally, screen may not allow reconnection by default by the usual

screen -list

screen -r <id>

normally allows reconnecting to a remote session after logging off. When a connection is lost before disconnecting from screen, you may need the “-x” option:

screen -x <id>

A downside of screen is the difficulty scrolling back in history. Although screen is a mature project, development is still ongoing.

Screen is a terminal multiplexer, and some prefer tmux over screen. Another option is using nohup.