Home/Glossary/What is tmux, and how does it keep tasks running after you disconnect?

What is tmux, and how does it keep tasks running after you disconnect?

Updated · airankrush

Term · tmux and persistent sessions

tmux is a terminal multiplexer. It opens a persistent "session" on the machine, and your command-line programs run inside that session rather than inside the terminal window in front of you. So when the window is closed or the connection drops, the session and the programs in it keep running. The next time you open a terminal, one command reattaches you and the earlier output is still there. It can also split one window into several panes so you can watch several programs at once. Note that it only covers the one case of the terminal going away: after the machine restarts, sleeps or shuts down, the session no longer exists and tasks have to be started again.

How it relates to renting a remote Mac

One fact first: when you use remote desktop, disconnecting does not close the terminal windows open on the remote desktop, and the tasks in them were still running anyway. So tmux is not a necessity here. What it adds is cover for a few other cases: closing a terminal window by mistake, the terminal app itself crashing, or wanting to switch from phone to computer and carry on watching the same task.

The basic usage is just three things:

  • tmux new -s work: create a session named work and start your task inside it;
  • press Ctrl-b and then d: leave the session while the task keeps running;
  • tmux attach -t work: reattach to that session.

Whether tmux is preinstalled on the machine is whatever your delivery notes say. If it is not, install it with Homebrew: brew install tmux.

When running long tasks such as Claude Code, putting them inside tmux and then disconnecting the desktop is common practice. See do long tasks stop when the remote connection drops? and how to keep long tasks running.

FAQ

After the machine restarts, do tasks in tmux resume by themselves?

No. After a restart the session is gone and tasks have to be started again. To have them come back automatically after a restart you need to set up auto-start separately with launchd. tmux only keeps them from being interrupted by a dropped connection in normal use.

I do not want to install anything. Does the system come with something similar?

macOS ships with a similar tool called screen. The version is fairly old, but it can do the basic "detach and reattach". Use whichever you are used to, and do not nest one inside the other.

Pricing and availability: see the plans page · Help center (中文) · Refund policy (中文) · Telegram Contact support

Back to home · Glossary