title: AWS SSM screen sessions do not persist
body: <p>I'm making a script with the Javascript AWS-SDK that sends commands to an EC2 instance in order to create a screen and then execute a process in said screen. After some time, SSM is supposed to restore the previously created screen and stop the process. However, after some tests, the screens don't seem to persist when using the following sequence of commands.</p>
  <pre class="lang-sh prettyprint-override"><code>// First command batch
  
  cd /home/ec2-user/
  screen -S server
  run process
  
  // Second command batch
  
  cd /home/ec2-user/
  screen -S server -X &quot;stop process&quot;
  </code></pre>
  <p>When using the second batch of commands, SSM returns an error saying that there are no screens or &quot;Must be connected to a Terminal&quot;. I'm at a loss. Why can't I use a screen?</p>