Close the terminal, the job stays
Close the terminal and the job inside tmux keeps running.
Close the outside terminal and the job inside tmux keeps running. The session sits on the server process, not in the window you just closed. To put detach and attach on one page for a colleague, open a room on oakmeet.
The result to search for is close the terminal and the job stays. tmux(1) says a session survives an accidental disconnect, such as an ssh timeout, or an intentional C-b d. Come back with tmux attach.
You detach the client, not the job
The outside terminal can close
Getting Started: detach from the outside terminal, then attach later from the same or another one. The walkthrough is close the xterm, go elsewhere, attach, and the compile is still on that server.
exit inside closes the window
The manual: when the shell command completes, the window closes. exit in the last pane is not detach. With no sessions left, exit-empty defaults to on and the server exits.
| Action | Command or keys | Does the job stay |
|---|---|---|
| Named session | tmux new -s job | Attached to this terminal |
| Detach on purpose | C-b then d | Session and programs continue |
| Close the terminal | The client is gone | The session stays by default |
| Come back | tmux attach -t job | Same session |
Four steps, then the window can close
- 01Open a session named job
Install tmux from your platform packages. Getting Started does not name one installer. After that,
man 1 tmuxis this manual. Thentmux new -s job. The wiki writes the same flag astmux new -smysession. With no-s, the first session is0. - 02Start the long command inside
A new session has one window, one pane, and a shell. The status line sits at the bottom; the session name is on the left. Start the program you want left running. You are still attached to this terminal.
- 03C-b d, then close the terminal
The default prefix is
C-b. Press Ctrl-b, release, thend. That is not Ctrl-d. The documented line is[detached (from session mysession)], with your session name. Then close the terminal. - 04Attach from a new terminal
tmux lslists sessions on the server. Thentmux attach -t job.tmux attachwith no-ttakes the most recently used session that has no client. The key list isC-b ?.
tmux new -s job
# start the long command, then press C-b d
tmux ls
tmux attach -t jobYou closed the outside terminal. exit inside the pane is what closes the window.
- Why the session survives the close
destroy-unattacheddefaults to off: after the last client detaches, the session is left in place. Set it to on and detach destroys the session.- Name already taken
- Session names must be unique. If
jobexists,tmux new -A -s jobattaches, or creates it. The wiki writestmux new -Asmysession. - Prefix was changed
prefixcan be another key. ThenC-b dis not detach.C-b ?lists bindings while the default prefix is still in force.
Put the four steps on one page
If two people need to agree which key counts as detach, draw new, C-b d, and attach on one board. oakmeet is a browser whiteboard: a space code, no account. It does not run tmux and it does not keep your process alive.
Align, then go back to the terminal. Next: start a room, or see create and join a space and features.
How is closing the terminal different from exit?
Closing the outside terminal, or an ssh timeout, leaves the session. exit in the pane ends the command and closes the window. With no sessions, the server exits.
Which session does tmux attach pick?
With no -t, it attaches the most recently used session that has no client. Name one with tmux attach -t job. tmux ls shows the names.
C-b d did not detach?
C-b is only the default prefix, and Ctrl must be released before d. If prefix changed, that pair is no longer detach-client. The binding list is prefix, then question mark.
Does oakmeet keep this job running?
No. oakmeet is a short-lived browser room and a board. The start link is only so you can lay out detach and attach. The job stays on that machine's tmux server.