Home How to use Tmuxinator to tail logs
Post
Cancel

How to use Tmuxinator to tail logs

Use Tmuxinator to open multiple panes to tail multiple logs at once.

Install Tmuxinator (I’m using Ubuntu)

1
sudo apt install tmuxinator

Create yaml file

Here is an example file called tomcat.yml that you place in you ~/.config/tmuxinator/ folder. If this folder doesn’t exist, create it in your home folder mkdir -p ~/.config/tmuxinator

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
name: tomcat
root: ~/

startup_window: logs
startup_panel: 6
windows:
  - logs:
      layout: tiled
      panes:
       - ssh username@server1 'journalctl -u tomcat9.service -f'
       - ssh username@server2 'journalctl -u tomcat9.service -f'
       - ssh username@server3 'journalctl -u tomcat9.service -f'
       - ssh username@server4 'journalctl -u tomcat9.service -f'
       - ssh username@server5 'journalctl -u tomcat9.service -f'
       - ssh username@server6 'journalctl -u tomcat9.service -f'

Generate SSH key if needed

If you are using SSH commands in your yaml file you will need to generate an SSH. Skip this if you already have one.

1
ssh-keygen -t rsa

Accept the default location and chose a passphrase if you’d like.

Copy keys to SSH servers

For each SSH server specified in your yaml file you will need to copy your SSH key there.

1
2
3
4
5
6
ssh-copy-id usename@server1
ssh-copy-id usename@server2
ssh-copy-id usename@server3
ssh-copy-id usename@server4
ssh-copy-id usename@server5
ssh-copy-id usename@server6

Start Tmuxinator

1
tmuxinator start tomcat

Detach session

CTL + B, D

Reattach session

1
tmux attach

Stop session

  1. CTL + B, D to detach
  2. tmuxinator stop tomcat
This post is licensed under CC BY 4.0 by the author.