Using tmux to Manage a Fleet of Robots


The title of this post ought to be “Using tmux to Manage a Fleet of Robots Incorrectly”. When I say manage here, I am talking about system configuration, code deployment and systems administration type tasks. Long term you really should be utilising tools like Ansible, Docker and Airbotics to keep your fleets Linux systems running as you intend. However, in reality it is often needed to do some quick maintenance operation to many Linux systems (or robots) at once even in the early days of a robotics startup when you might have a small fleet and maybe not yet settled on a setup using one of the aforementioned “proper” tools. tmux synchronise panes can help here, allowing you to send commands to multiple terminal sessions at once.

A Very Brief Introduction to tmux

tmux is a command line application that is a terminal session multiplexer. It allows for terminal sessions to be resumed after connection loss, multiple panes and tabs in the same session and a whole host of other benefits. See this page for a more comprehensive introduction if you are not already familiar.

If you haven’t already go ahead and download tmux.

sudo apt update
sudo apt install tmux

You can run tmux…


…and play around with some of the commands from the tmux Cheat Sheet.

Getting To The Point

Before we get started we need to either create, or modify your existing tmux configuration file.

For a local user specific configuration file…

nano ~/.tmux.conf

For a global configuration file…

nano /etc/tmux.conf

We will add the following line to this configuration file.

bind-key y set-window-option synchronize-panes\; display-message "Synchronise mode toggle"

This will set Ctrl + b then y to toggle pane synchronisation mode.

Now we need to make sure all out tmux sessions are closed and restart tmux for the changes in the configuration file to take effect.

Once we have a tmux session open we can ssh into several other robots within separate panes. If you have remote field robots and are looking to establish remote connections it might be worth reading my post on setting up a VPN.

Inside tmux use Ctrl + b then % to split panes vertically or Ctrl + b then " to split panes horizontally. You can navigate between panes with Ctrl + b followed by an arrow key in the direction you with to move your cursor.

In each pane you can establish an ssh connection to each of the robots you wish to run commands on using your usual IP addresses and credentials.

Once you have a pane with a separate connection for each robot you wish to modify you can enable pane synchronisation using Ctrl + b then y or whatever key you set inside the tmux configuration file. Now when you type commands they will be entered across all panes within your current tmux window.

Hopefully that might get you out of a hole in a pinch but as I said before I wouldn’t recommend using this for long term system administration.

Hey you!

Found this useful or interesting?

Consider donating to support.

Any question, comments, corrections or suggestions?

Reach out on the social links below through the buttons.