Option 1: nohup
The best way is often the simplest.
nohup long-running-command &
It was made specifically for this, it even logs stdout to
nohup.out.
Option 2: bg + disown
ctrl+z
bg
disown -h
If you want to "background" already running tasks, then Ctrl+Z then run bg to put your most recent suspended task to background, allowing it to continue running. disown will keep the process running after you log out. The -h flag prevents hangup.
screen and others can do it, but that's not what they're for. I recommend nohup for tasks you know you are going to leave behind and bg for tasks you're already running and don't want to re-start.
Source:
https://askubuntu.com/questions/8653/how-to-keep-processes-running-after-ending-ssh-session