The problem: Need to start multiple services all at once and also be able to monitor them somehow (there's no way to do logging to a file, because custom CLI tool).
Example use case: Spin up dev server in one click - start server, IDE like VS Code, and Docker subservices (database etc), de clutter multiple terminal windows into one and to monitor logs more easily.
sudo EDITOR=nano crontab -e
@reboot bash /path/to/script.sh
script.sh
#!/bin/bash
SESH="startupIO"
tmux has-session -t $SESH 2>/dev/null
if [ $? != 0 ]; then
## 8000
tmux new-session -d -s $SESH -n "rhttpds"
tmux send-keys -t $SESH:rhttpds "bash /home/user/Desktop/services/startup/rhttpds.sh" C-m
## 8024
tmux new-window -t $SESH -n "rhttpds80"
tmux send-keys -t $SESH:rhttpds80 "bash /home/user/Desktop/services/startup/rhttpds80.sh" C-m
## 2121
tmux new-window -t $SESH -n "uploadFTP"
tmux send-keys -t $SESH:uploadFTP "bash /home/user/Desktop/services/startup/upload-FTP.sh" C-m
tmux set-option -t $SESH status on
tmux set-option -t $SESH status-style fg=white,bg=black
tmux set-option -t $SESH mouse on
tmux select-window -t $SESH:rhttpds80
fi
Reconnect to terminal
tmux attach-session -t startupIO
Switch between windows
Previous: Ctrl+B then P
Next: Ctrl+B then N
Other shortcuts: https://tmuxcheatsheet.com/
Stop all
tmux kill-ses -t startupIO
Top comments (0)