I am trying to create a new tmux session and execute the command 'vagrant up'. 'Vagrant up' takes more than 3 hours so I want to detach the session so that I can come back later and check the status of that command by attaching back to the same session.
I followed the answer specified in the StackOverflow post to accomplish the same.
I am getting the error no session found
. Here is my code:
$cat tmux_sh.sh
#!/bin/bash
echo "step 1"
tmux new-session -d -s rtb123 'vagrant up'
echo "step 2"
tmux detach -s rtb123
$./tmux_sh.sh
step 1
step 2
session not found: rtb123
Detach From A Session To detach (meaning exit the window to come back to later) from the tmux session, use CTRL + b then d (hold ctrl, press b, let go of both of the keys, and press d). Whatever program(s) you are running in the tmux session will continue going without you.
Basic Tmux UsageUse the key sequence Ctrl-b + d to detach from the session. Reattach to the Tmux session by typing tmux attach-session -t my_session .
Using the Prefixes to Control Tmux By default, the prefix is CTRL+B. That is, we have to press the keys CTRL+B and then the command. For example, to create a new session, the command would be C. So, to create a new session we need to press CTRL+B and next C – CTRL+B, C.
You can—and often will—have multiple tmux sessions on a single system, so you want to be able to see what they are. You can also show sessions using the shortcut ctrl–b–s.
Start a shell, and send vagrant up to it, so you can see the errors.
tmux new-session -d -s rbt123
tmux send-keys 'vagrant up' C-m
tmux detach -s rtb123
The C-m
means hit return.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With