AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / unix / 问题 / 445307
Accepted
Nemo
Nemo
Asked: 2018-05-23 02:44:46 +0800 CST2018-05-23 02:44:46 +0800 CST 2018-05-23 02:44:46 +0800 CST

仅在缺少时打开具有特定名称的新 tmux 窗口

  • 772

我需要并行启动多个命令,每个命令都在同一个会话中各自的 tmux 窗口中,确保每个命令只有一个实例在运行。

理想情况下,窗口将遵循固定的命名和顺序,以便于识别它们。

我认为过去我曾经做过这样的事情:

tmux new-window -t cmd1 -n cmd1 { my command }

然后 tmux 将在最后一个会话中创建一个窗口,命名cmd1并在第一个位置(后面是 cmd2 等),或者如果窗口已经存在,则什么也不做。

tmux
  • 1 1 个回答
  • 3412 Views

1 个回答

  • Voted
  1. Best Answer
    Nemo
    2018-05-23T02:44:46+08:002018-05-23T02:44:46+08:00

    如果我使用实际整数作为索引,它对我有用:

    $ tmux new-window -t 1 -n cmd1 -d sleep 60
    $ tmux new-window -t 1 -n cmd1 -d sleep 60
    create window failed: index in use: 1
    

    使用非整数索引将不起作用:

    $ tmux new-window -t cmd1 -n cmd1 -d sleep 60
    can't find window i1
    

    手册页中的引用(tmux 2.5-4):

     new-window [-adkP] [-c start-directory] [-F format] [-n window-name] [-t target-window] [shell-command]
                   (alias: neww)
             Create a new window.  With -a, the new window is inserted at the next index up from the specified target-window, moving windows up if necessary, otherwise target-window is the new window location.
    
             If -d is given, the session does not make the new window the current window.  target-window represents the window to be created; if the target already exists an error is shown, unless the -k flag is used, in which case it is destroyed.
    
    • 2

相关问题

  • 在 tmux 会话中启动另一个脚本的 bash 脚本

  • 是否可以在不连接的情况下将输入发送到 tmux 会话?

  • tmux 和控制序列字符问题

  • Bash - 从用户那里获取输入并在 tmux 中发送具有该输入的命令

  • 从 tmux 会话回显某些内容到基础会话

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    如何将 GPG 私钥和公钥导出到文件

    • 4 个回答
  • Marko Smith

    ssh 无法协商:“找不到匹配的密码”,正在拒绝 cbc

    • 4 个回答
  • Marko Smith

    我们如何运行存储在变量中的命令?

    • 5 个回答
  • Marko Smith

    如何配置 systemd-resolved 和 systemd-networkd 以使用本地 DNS 服务器来解析本地域和远程 DNS 服务器来解析远程域?

    • 3 个回答
  • Marko Smith

    如何卸载内核模块“nvidia-drm”?

    • 13 个回答
  • Marko Smith

    dist-upgrade 后 Kali Linux 中的 apt-get update 错误 [重复]

    • 2 个回答
  • Marko Smith

    如何从 systemctl 服务日志中查看最新的 x 行

    • 5 个回答
  • Marko Smith

    Nano - 跳转到文件末尾

    • 8 个回答
  • Marko Smith

    grub 错误:你需要先加载内核

    • 4 个回答
  • Marko Smith

    如何下载软件包而不是使用 apt-get 命令安装它?

    • 7 个回答
  • Martin Hope
    rocky 如何将 GPG 私钥和公钥导出到文件 2018-11-16 05:36:15 +0800 CST
  • Martin Hope
    Wong Jia Hau ssh-add 返回:“连接代理时出错:没有这样的文件或目录” 2018-08-24 23:28:13 +0800 CST
  • Martin Hope
    Evan Carroll systemctl 状态显示:“状态:降级” 2018-06-03 18:48:17 +0800 CST
  • Martin Hope
    Tim 我们如何运行存储在变量中的命令? 2018-05-21 04:46:29 +0800 CST
  • Martin Hope
    Ankur S 为什么 /dev/null 是一个文件?为什么它的功能不作为一个简单的程序来实现? 2018-04-17 07:28:04 +0800 CST
  • Martin Hope
    user3191334 如何从 systemctl 服务日志中查看最新的 x 行 2018-02-07 00:14:16 +0800 CST
  • Martin Hope
    Marko Pacak Nano - 跳转到文件末尾 2018-02-01 01:53:03 +0800 CST
  • Martin Hope
    Kidburla 为什么真假这么大? 2018-01-26 12:14:47 +0800 CST
  • Martin Hope
    Christos Baziotis 在一个巨大的(70GB)、一行、文本文件中替换字符串 2017-12-30 06:58:33 +0800 CST
  • Martin Hope
    Bagas Sanjaya 为什么 Linux 使用 LF 作为换行符? 2017-12-20 05:48:21 +0800 CST

热门标签

linux bash debian shell-script text-processing ubuntu centos shell awk ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve