我运行这个:
ssh -t -vvv -i ~/.ssh/druid-keypair -o StrictHostKeyChecking=no ubuntu@${INSTANCE_ADDRESS} <<EOI
# Setup Oracle Java
...
# Install dependencies - mysql must be built from source, as the 12.04 apt-get hangs
export DEBIAN_FRONTEND=noninteractive
sudo debconf-set-selections <<< 'mysql-server-5.5 mysql-server/root_password password diurd'
sudo debconf-set-selections <<< 'mysql-server-5.5 mysql-server/root_password_again password diurd'
sudo apt-get -q -y -V --force-yes --reinstall install mysql-server-5.5
echo "ALL DONE with druid environment setup!"
exit
EOI
注意:我已经尝试在ssh中使用-t或不使用-t。
-vvv的调试输出是这样的:
...
ldconfig deferred processing now taking place
ALL DONE with druid environment setup!
debug1: client_input_channel_req: channel 0 rtype exit-status reply 0
然后,该过程将永远存在。ssh命令为什么不结束?我尝试了使用-t和不使用,也尝试过使用出口和不使用。没关系:(
更新:当我在脚本末尾键入“ jobs”时,我看到:
JOBS:
[1]- Running nohup bin/zookeeper-server-start.sh config/zookeeper.properties 2>&1 > /dev/null &
[2]+ Running nohup bin/kafka-server-start.sh config/server.properties 2>&1 > /dev/null &
如何运行这些服务,但仍然有一个ssh会话结束?
更新:我现在手动取消这些过程。事情仍然没有退出。WTF队友?
更新:逐行执行时,有两个命令不会在不按CR的情况下返回shell:
nohup bin/zookeeper-server-start.sh config/zookeeper.properties &
nohup bin/kafka-server-start.sh config/server.properties &
通常,如果仍有后台连接仍打开,则SSH终端会话会挂起。通过后台连接,我的意思是:
通过输入已~#
挂起的SSH终端,查看在已挂起的SSH会话上仍处于活动状态的连接。
可能是您的脚本正在打开您没有意识到的会话。或者您的远程计算机的终端配置.profile
(例如或.bashrc
等)中可能包含一些建立会话的内容。祝你好运!
顺便说一下,OpenSSH客户端提供的其他一些转义序列也可能有用:
Supported escape sequences:
~. - terminate connection (and any multiplexed sessions)
~B - send a BREAK to the remote system
~C - open a command line
~R - Request rekey (SSH protocol 2 only)
~^Z - suspend ssh
~# - list forwarded connections
~& - background ssh (when waiting for connections to terminate)
~? - this message
~~ - send the escape character by typing it twice
(Note that escapes are only recognized immediately after newline.)
另一件事,如果您希望SSH仅运行命令并立即退出-即您不希望进行远程终端会话-可以使用-f
选项ssh
。这将迫使SSH连接成为后台作业。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句