How to keep program running after SSH disconnection? [duplicate]
Solution 1:
'screen' is most likely what you want. It allows you to disconnect and reconnect at will. After you SSH into the server, run screen before starting your program. Ctrl-a, Ctrl-d will disconnect you (the program continues regardless). On your return, 'screen -r' will reconnect you as if you'd never been away.
Think of it as VNC or RDP for text terminals. Search for 'using screen' for many tutorials.
Edited to add: These days I would recommend tmux instead, especially if used in conjunction with the script tmx. The ability to split panes (vertically and horizontally) and resize them is a huge boon over screen.
Solution 2:
nohup
is a command that will run another command, and make it immune to the "hangup" signal.
You run it as simply as:
nohup command
but you will also need to redirect stdin, stdout and stderr. See the man page for more info.
You'll also probably want to put it in the background.
You will also need to know the kill
command to eventually kill it.