Preventing a dropped connection from killing a running job.
THE PROBLEM
A long-running command over SSH dies if the connection drops. A large database import, a big rsync or a system upgrade can take hours, and a lost connection means starting again, or worse, leaving the system in a half-finished state.
THE SOLUTION
screen and tmux create persistent sessions on the server. You attach, start work, and can detach or lose connection without the work stopping. Reattach later and it is still running.
BASIC USE WITH SCREEN
Start a named session, run your command, detach with the key combination, and reattach later by name.
BASIC USE WITH TMUX
Similar, with more features: split panes, multiple windows, better status display.
WHICH TO USE
Either. tmux is more capable; screen is more likely to be already installed.
WHEN TO USE THEM
Any command that might take more than a few minutes: system upgrades, large imports, migrations, long rsync transfers.
THE HABIT
Start a session before beginning anything substantial. Realising afterwards that you should have is a bad moment.