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)
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
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.
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.
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
tmuxinator start tomcat
Detach session
CTL + B, D
Reattach session
tmux attach
Stop session
- CTL + B, D to detach
tmuxinator stop tomcat