내용으로 건너뛰기

SSM Session Hangs

0

I am using the SSM Manager to log in to a EC2 instance. I then run this command to view logs

tail -f logs.txt

I see the logs for a while but then the command just hangs. I press Ctrl+C and nothing happens. This is on WSL2. Has anyone run into this and know how to fix?

  • Sounds like a classic buffering issue – when the file isn’t getting new data, tail -f sits idle waiting for more, so it can feel like it’s hung.

    Try these steps

    1. Add a timeout tail -f --retry --sleep-interval=2 logs.txt

    This will poll the file every 2 seconds instead of blocking indefinitely.

    1. Force line buffering stdbuf -oL tail -f logs.txt

    This tells the system to flush output line‑by‑line, which can break the stall.

    1. Check if the file is being rotated If the log is being rotated (size resets), tail -F (capital F) will follow the file name rather than the descriptor.

    2. Verify WSL2 networking Sometimes WSL2’s networking quirks cause the session to freeze.

      • Restart WSL: wsl --shutdown then reopen.
      • Ensure the EC2 instance is reachable via SSM and the session didn’t drop.
    3. Alternative: Use tmux or screen Run the command in a tmux session so it survives network hicups.

    If none of that helps, check the SSM Agent logs on the instance (/var/log/amazon/ssm) for errors or connectivity drops .¹

질문됨 2달 전98회 조회
2개 답변
0

Hello.

I tried it in my environment, but I can't reproduce the problem.
It's possible that the problem cannot be reproduced because we are testing it on a temporary server with a small amount of logs, but it could also be a problem with the Session Manager plugin differences.
What version of the Session Manager plugin are you using?
I am using the latest version in my environment.
https://docs.aws.amazon.com/systems-manager/latest/userguide/plugin-version-history.html

session-manager-plugin --version

The Session Manager plugin also allows you to output logs for the plugin itself, so try setting this and checking to see if any errors occur.
https://docs.aws.amazon.com/systems-manager/latest/userguide/install-plugin-configure-logs.html

전문가
답변함 2달 전
AWS
전문가
검토됨 한 달 전
  • $ session-manager-plugin --version 1.2.764.0

  • I am also using the same version. Have you checked the Session Manager plugin logs?

0

This issue could be related to how SSM Agent handles long-running sessions, which can sometimes cause the managed node to become unresponsive or crash.

Here are some potential solutions:

  1. Decrease the SSM Agent log retention duration for Session Manager. This is a recommended solution when managed nodes become unresponsive during long-running sessions.

  2. If you're unable to terminate the session normally, you can force termination using the AWS CLI command:

aws ssm terminate-session --session-id your-session-id
  1. If you're experiencing issues specifically with Windows Server 2025 instances, ensure that WMIC is installed as an optional feature.

  2. You might want to enable debug logging for SSM Agent to troubleshoot further. This involves:

  • Connecting to the managed node
  • Making a copy of the seelog.xml.template file and renaming it to seelog.xml
  • Editing the file to change the minlevel from "info" to "debug"
  • Restarting the SSM Agent service
  1. If you're using Terraform to manage your instances and experiencing timing issues with SSM commands, consider adding delays between instance creation and command execution.

The most likely solution for your specific issue is to terminate the hanging session and start a new one, or to decrease the SSM Agent log retention duration to prevent future occurrences.
Sources
Troubleshooting Session Manager - AWS Systems Manager
End a session - AWS Systems Manager
Viewing SSM Agent logs - AWS Systems Manager
Troubleshoot issues with Amazon EC2 Windows instances - Amazon Elastic Compute Cloud
Running SSM Commands after ec2 instance is created (Terraform) | AWS re:Post

답변함 2달 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

관련 콘텐츠