gpt4 book ai didi

bash - 启动一个新的 tmux session 并分离它,所有这些都在一个 shell 脚本中

转载 作者:行者123 更新时间:2023-11-29 08:53:59 25 4
gpt4 key购买 nike

我正在尝试创建一个新的 tmux session 并执行命令“vagrant up”。 “Vagrant up”需要 3 个多小时,所以我想分离 session ,以便稍后返回并通过附加回同一 session 来检查该命令的状态。

我遵循了 StackOverflow post 中指定的答案完成同样的任务。

我收到错误消息找不到 session 。这是我的代码:

    $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,并将 vagrant up 发送给它,这样你就可以看到错误。

tmux new-session -d -s rtb123
tmux send-keys 'vagrant up' C-m
tmux detach -s rtb123

C-m 表示回车。

关于bash - 启动一个新的 tmux session 并分离它,所有这些都在一个 shell 脚本中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33426159/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com