I was having some trouble when trying to run 2 tmux sessions on startup and I can not for the life of me figure out the problem. To run 1 tmux session I use the following code:
sudo -H -u USERNAME tmux new-session -d -s session1 'python3 Main.py'
I thought to run 2 session I just needed to copy paste this line and change the script name and session name. But this doesn’t do anything in my case because when I go to my server it say only the first tmux session is running. Does anyone know what I am doing wrong?
CodePudding user response:
Multiplexers support multiple sessions. Each multiplexer session has its own set of terminals and controlling processes which it is running. The client must choose a session to attach to, and will only be able to see the output of the controlling processes in that session. Sessions can be given names to make it easy for the client to choose the correct session.
Tmux by default will only run one server process per user, and this server process can have multiple sessions. A Tmux client and the server communicate via a Unix domain socket in the /tmp directory. And a bit easier to do this is just starting the desired sessions within the same set of instructions as start.
tmux start \; new-session -d -s session1 \; new-session -d -s session2.
Add this command in startup script so that you can run 2 tmux sessions simultaneously.