How to keep sessions running after disconnect with tmux
Updated 11/29/2026
If you close the SSH connection, processes started in the terminal stop. tmux solves this: sessions stay alive on the server and you can reconnect to them anytime.
1. Install
apt-get update -y
apt-get install -y tmux
2. Start a session
tmux new -s work
3. Detach (the session stays running)
Press Ctrl+b then d. You can close SSH; the process continues.
4. Reconnect
tmux attach -t work
tmux ls # list sessions
When it is useful
- Long migrations or backups that must not be interrupted.
- Builds or database imports that take hours.
- Watching a live process without having to keep SSH open.
tmux or systemd?
tmux is for temporary, interactive tasks. For permanent services that must start on their own, use a systemd service.
Put this guide into practice on your own VPS
EU cloud servers, billed hourly, ready in minutes, with one-click installs for dozens of apps.
See pricingRelated tutorials
Error tracking for your applications with GlitchTip
Catch production exceptions with the Sentry SDKs on a small server: the project, the DSN, alerts and uptime.
Updated 11/29/2026Dev environmentsTest your application's email with smtp4dev
Send the email from Laravel, WordPress, Node or Python to a test SMTP server and read it in a web inbox, without it ever reaching real customers.
Updated 11/29/2026Dev environmentsHow to set up a staging environment
Test changes on a copy of production before shipping them, to avoid surprises.
Updated 11/29/2026