Contact us
Servers 1 min read · 11/2020

Moving Running Processes to Tmux

A simple guide to moving a long-running process from your console to Tmux

If you have ever started a command in your server console that ran longer than you expected and you already needed to log out, here is a simple way to move the command to Tmux.

Installing dependencies

This guide uses commands that are not usually part of a basic Linux installation. They are easy to install, though – on Debian/Ubuntu it's as simple as this:

bash
apt install tmux reptyr

Moving the process

  1. Suspend the process: press Ctrl+Z
  2. Resume the process in the background: bg
  3. Disown the process: disown %1
  4. Start Tmux: tmux or tmux attach (if you already have a tmux session running)
  5. Find the right PID: ps a | grep <$PROCESS_NAME>
  6. Restore the process in Tmux: reptyr <$PID>

The original procedure is taken from https://www.linkedin.com/pulse/move-running-process-screen-bruce-werdschinski/, and a tmux tutorial (in Czech) can be found, for example, on root.cz

Share
LinkedIn Facebook

Need more than an article?

Get in touch with no obligation – a few sentences about what you are dealing with are enough.

Read on

Similar articles

More notes from operations and development.

All advice