30

I have a shell script that is enabled as service to start multiple shell scripts e.g.

service started script -> script1, script2 ,script3 

script1 should open a program in a tmux window, and it does work just fine if I manually start the script via ./script1.sh, however when started at boot via the service started script it does not with the above error:

open terminal failed: not a terminal

Why is this happening?

4

2 回答 2

41

这里已经有一个答案,但我认为这个链接更好地总结了它。简而言之,使用-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).
于 2015-06-08T11:17:40.203 回答
13

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

tmux new-session -s username -d

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

于 2017-02-01T17:42:17.150 回答