Skip to content

Does tmux keep running when your Mac sleeps?

tmux can keep a terminal session alive after you detach from it. It does not keep a sleeping Mac executing a local job. Session persistence, sleep prevention, and input protection solve different problems.

What tmux protects you from

tmux runs terminal sessions inside a server process. You can detach a client and attach again later, with the shell and its programs still there while the host remains running. This is useful when a terminal window is an inconvenient home for a long job.

It is not a checkpoint system. Restarting the host, killing the tmux server, or losing the underlying process is different from detaching a terminal client. Make your job save durable output if you need recovery after a reboot.

Start a named session for a build

With tmux installed, create a session with an easy-to-remember name. Run your build or tests inside it. The default detach shortcut is Control-B followed by D; it returns you to the shell outside tmux.

Use tmux attach -t build when you want to return, or tmux ls to list sessions. If you have customized your prefix key, use your configured shortcut.

tmux new -s build

Add sleep prevention for a local job

Inside the session, you can wrap your job with caffeinate. For example, caffeinate -i make requests prevention of idle system sleep while make runs. Detaching tmux does not remove the need to keep the host awake.

You can also use appropriate macOS sleep settings or Warden’s optional sleep prevention while input is locked. Choose the smallest setup that meets your needs: tmux for reattaching, sleep prevention for execution, and an input lock for an unattended visible screen.

Local tmux and remote tmux behave differently

If tmux and your job run on a remote server, your laptop is only the client. A lost SSH connection can leave the remote tmux session available to attach to again, provided that server and job remain running. If tmux runs on your Mac, your Mac is the host that must stay awake.

Before stepping away, identify where the process actually runs. A terminal connected over SSH looks similar to a local terminal, but keeping the laptop awake does not fix a sleeping or restarted remote machine. Likewise, keeping a remote server alive does not preserve an unrelated local build.

tmux does not block accidental typing

When a tmux pane is active, keystrokes still reach it. Control-C may interrupt the program in the foreground, and text can still be entered into a shell or an agent prompt. Detaching hides that pane; it does not lock the entire Mac.

Use Warden when you want the terminal to stay visible while keyboard, mouse, and trackpad input are blocked. Use the macOS screen lock when hiding desktop contents is the priority. Warden is not a remote session manager and cannot restart a failed job.

A quick check before you leave

  • Confirm whether the job runs locally or on a remote host.
  • Detach and reattach once during a disposable test job.
  • Verify that the host remains awake for the intended duration.
  • Make sure logs and outputs are saved outside the terminal scrollback.
  • If an AI agent can request approval, plan to return and review it; input locking does not answer prompts.

Sources

Related guides