If you’ve ever started a long-running task—like a database migration— only to have your terminal or SSH connection drop, screen is your lifesaver.
It keeps processes running in the background so you don’t have to babysit your terminal.
Start a named session so you can easily reattach later:
# db_migration is just a name here
screen -S db_migrationInside the session, start your process:
python3 migrate_database.pyDetach the session without stopping your process:
Press Ctrl + A, then D
Your process keeps running even if you close your terminal or your network drops.
Reconnect to your session anytime:
screen -r db_migrationWhen your task is done and you’re finished with the session:
Press Ctrl + D to terminate the session.
✨ Why this is magic: Your scripts, migrations, or backups keep running safely in the background, even on weak or flaky networks.