【问题标题】:SSH into EC2 instance while it is running a script运行脚本时通过 SSH 连接到 EC2 实例
【发布时间】:2017-05-03 03:08:54
【问题描述】:

我有一个用于填充数据库的 ec2 实例。我有一个 python 脚本,我通过输入: nohup python populate_db.py &。这有效,数据库开始填充。但是,如果我离开 ssh 会话,然后在运行时尝试重新加入,我会在添加 vvv 标志时得到以下输出:

OpenSSH_7.4p1, OpenSSL 1.0.2k  26 Jan 2017
debug1: Reading configuration data /home/me/.ssh/config
debug1: Reading configuration data /etc/ssh/ssh_config
debug2: resolving "ec2-xx-xxx-xxx-x.compute-1.amazonaws.com" port 22
debug2: ssh_connect_direct: needpriv 0
debug1: Connecting to ec2-xx-xxx-xxx-x.compute-1.amazonaws.com 
[xx.xxx.xxx.x] port 22.
debug1: Connection established.
debug1: key_load_public: No such file or directory
debug1: identity file .ssh/ec2key.pem type -1
debug1: key_load_public: No such file or directory
debug1: identity file .ssh/ec2key.pem-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_7.4
ssh_exchange_identification: read: Connection reset by peer

此外,我的 cloudwatch 日志似乎停止记录,并且 CPU 使用率在飙升到最高 80% 后下降到 6% 左右,所以感觉好像有什么东西可能要崩溃了。

有没有办法找出问题所在/解决这个问题?

【问题讨论】:

  • 尝试使用screen 而不是nohup

标签: amazon-web-services ssh amazon-ec2


【解决方案1】:

原来我的脚本有内存泄漏。我没有在 EC2 上进行内存监控,但是在本地运行它,使用中的内存在几分钟内攀升至 2.5 GB(远远超过 t2.micro 可以处理的容量)。

【讨论】:

    猜你喜欢
    • 2018-01-30
    • 2020-03-13
    • 1970-01-01
    • 1970-01-01
    • 2011-10-30
    • 1970-01-01
    • 1970-01-01
    • 2019-08-08
    • 2021-12-10
    相关资源
    最近更新 更多