【问题标题】:tmux open terminal failed: not a terminaltmux 打开终端失败:不是终端
【发布时间】:2014-10-02 04:39:04
【问题描述】:

我有一个作为服务启用的 shell 脚本来启动多个 shell 脚本,例如

service started script -> script1, script2 ,script3 

script1 应该在 tmux 窗口中打开一个程序,如果我通过 ./script1.sh 手动启动脚本,它确实可以正常工作,但是当通过服务启动脚本启动时,它不会出现上述错误:

open terminal failed: not a terminal

为什么会这样?

【问题讨论】:

  • 一个服务通常没有关联的 tty(终端)。它是一个多用户操作系统,还没有人登录,它会写入谁的终端?为什么这些服务需要交互式外壳?
  • 有很多脚本在做不同的事情备份等等......但是有问题的脚本在 tmux 窗口中运行我的世界服务器
  • 好的,发布脚本的 tmux 位,默认情况下,如果您在那里有一个新会话,它将尝试附加到当前 tty(因此错误) '将需要添加一个 -d 参数来防止这种情况
  • tmux new -s minecraft "java -args minecarft.jar nogui"
  • 试试 tmux new -d -s minecraft "java -args minecarft.jar nogui"

标签: shell tmux systemd


【解决方案1】:

here 已经有答案了,不过this link 我觉得总结的比较好。简而言之,使用-t 标志:

ssh -t host tmux attach

如果您想将其设置到您的 .ssh/config 文件中,请在 ssh_config 手册页中查找 RequestTTY 选项:

 RequestTTY
         Specifies whether to request a pseudo-tty for the session.  The
         argument may be one of: ``no'' (never request a TTY), ``yes''
         (always request a TTY when standard input is a TTY), ``force''
         (always request a TTY) or ``auto'' (request a TTY when opening a
         login session).  This option mirrors the -t and -T flags for
         ssh(1).

【讨论】:

  • 虽然这个答案有我在谷歌上搜索的答案,但这个问题实际上并不涉及 SSH;这是关于启动脚本的。
【解决方案2】:

我认为问题在于该服务没有关联的 tty。我发现的一种解决方法是将脚本中的 tmux 调用更改为

tmux new-session -s username -d

(用户名是为其启动服务的用户)

【讨论】:

    猜你喜欢
    • 2017-12-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-10-07
    • 2023-01-03
    • 2015-05-30
    • 1970-01-01
    • 2017-06-12
    相关资源
    最近更新 更多