Shared server guidance · Question & answer

How do I keep an interactive Linux task available after an SSH disconnection?

tmux keeps a terminal session on the server so you can detach and reconnect after an SSH interruption. It is useful for attended maintenance or investigation. It does not provide durable restart after a reboot, automatic failure recovery or the lifecycle guarantees expected of a production service manager.

BeginnerLinux VPS and dedicated servers with GNU utilities
Go to the answer

Before you start

  • tmux is installed and the task is suitable for an interactive server session.

Instructions

1. Create or inspect a named session

Use a distinct session name for the task and the intended account. Review existing sessions first so you do not accidentally create duplicate long-running work.

Remote Linux shell
tmux ls
tmux new-session -s server-review

No existing sessions is a normal result from tmux ls. The second command opens a new server-side terminal session.

2. Detach and return deliberately

Inside tmux, press Ctrl+B, release the keys, then press D to detach. From a later SSH connection using the same account, attach to the named session.

Remote Linux shell
tmux attach-session -t server-review

The existing process output should reappear. If another operator shares the session, coordinate keyboard input to avoid conflicting actions.

Check the result

  • The original task remains in the same session after reconnecting. Confirm its own completion result before closing that session.

Troubleshooting

The session vanished after reboot
tmux sessions are processes, not persistent job definitions. Use a supported service or scheduler for restartable production workloads.
A session is not found
Check the SSH account, host and exact session name before starting duplicate work.

Official references

Use the documentation for your installed version when a flag, service name or platform feature differs.