When I run a command on a machine that I am ssh’ed into, most of the time I want to kill the connection but have the command continue to execute.
There are several ways to detach a process from the current shell:
The first is to start the process with:
nohup command &
However, I usually start a command and forget to detach it initially. An easy way to detach a currently running process from a shell is like this:
Ctrl-Z
bg
disown %1
These methods daemonise a running process and make the process ignore the SIGHUP command so that when you close you shell or ssh connection, the command continues to run. For more information check out the man pages for disown and nohup.