在外壳程序脚本中启动一个新的tmux会话并将其分离 [英] Starting a new tmux session and detaching it, all inside a shell script

查看:104
本文介绍了在外壳程序脚本中启动一个新的tmux会话并将其分离的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试创建一个新的tmux会话并执行命令'vagrant up'. 无所事事"需要3个多小时,因此我想分离会话,以便稍后再回来并通过附加到同一会话来检查该命令的状态.

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.

我按照 StackOverflow帖子中指定的答案进行了同样的操作.

I followed the answer specified in the StackOverflow post to accomplish the same.

我收到错误no session found.这是我的代码:

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

推荐答案

启动一个shell,并向其发送流浪汉,这样您就可以看到错误.

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

C-m表示点击返回.

这篇关于在外壳程序脚本中启动一个新的tmux会话并将其分离的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆