AI Crawler · Collection Records

Bot summary · Last 24 hours

tmux — session-preserving terminal

A terminal multiplexer that keeps your session alive even if the connection drops during remote work. Essential for deployments and long-running tasks.
Markdown source·Anything to add or correct?

💬 "tmux commands"

tmux maintains sessions on the server. Even if ssh disconnects, tasks keep running.

It is the standard tool for safely running long deployments, batch jobs, and log following.

  • Concept: creates virtual terminals to manage sessions, windows, and panes.
  • Session: create with new and reattach with attach.
  • Split: " vertical split, % horizontal split, move with arrow keys.
  • Prefix key: defaults to Ctrl+b, then combine it with another key.

Commonly used options

OptionDescription
new -s <name>Create a named session
attach -t <name>Reattach to an existing session
lsView the session list
-d attachDetach other clients and attach

Three essential command combinations

  • tmux new -s deploy — create a session for deployment
  • tmux ls — check the current session list
  • tmux attach -t deploy — reattach to the deployment session after disconnection

💬 "Show me an example for comparing before and after performance tests"

Here are common situations you encounter on production servers, organized in order.

Step 1 · Create a session

Create a named session before starting work.


tmux new -s deploy

Step 2 · Run the task

Start a long-running task inside the session.


cd /opt/app && ./bin/deploy.sh 2>&1 | tee /tmp/deploy.log

Step 3 · Detach and reattach

Detach with Ctrl+b d, then reattach to check progress.


tmux attach -t deploy

In practice, it's used like this

1. Long-running deployment

Situation — If ssh disconnects during a 20-minute deployment, the task dies.


tmux new -s deploy 'bash -lc "./bin/deploy.sh 2>&1 | tee /tmp/deploy.log"'

Result — Deployment runs inside the session and continues even if the connection drops.

Point — After reattaching, check progress by tailing the log file.

2. Long-term batch monitoring

Situation — You want to watch an overnight batch job in real time.


tmux new -s batch 'tail -F /var/log/app/batch.log'

Result — You can attach at any time to view logs, and collection continues even after you leave.

Point — Giving each session a task-specific name makes it easy to distinguish multiple jobs.

Things to keep in mind

  • If you pass a command as an argument and it finishes, the tmux session also exits (keep a log file for review).
  • Sessions disappear on server reboot. For permanent execution, set it up as a systemd service.
  • If you don't know the prefix key (Ctrl+b), it can look like key input isn't working.

Actual execution screen

This is the result of checking the tmux session list and reattaching to the deployment session.

!tmux command execution result: session list and deployment progress

Production server


Source (HTML): https://games.aidebatehub.com/programs/linux/remote/tmux.html This file is an auto-generated Markdown twin of the DevHub document.

Visitor Comments

Loading…
💬 Comments: 0 · Author type: human | Built: 2026-10-30T20:31:00+09:00