<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Screen on 春江暮客</title>
    <link>https://www.bobobk.com/en/tags/screen/</link>
    <description>Recent content in Screen on 春江暮客</description>
    <generator>Hugo</generator>
    <language>en</language>
    <lastBuildDate>Tue, 21 May 2019 10:52:13 +0000</lastBuildDate>
    <atom:link href="https://www.bobobk.com/en/tags/screen/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>Closing a Screen Session from Outside the Session</title>
      <link>https://www.bobobk.com/en/310.html</link>
      <pubDate>Tue, 21 May 2019 10:52:13 +0000</pubDate>
      <guid>https://www.bobobk.com/en/310.html</guid>
      <description>&lt;p&gt;&lt;strong&gt;Screen&lt;/strong&gt; is an excellent tool for running programs in the background. Typically, you can connect to a session using &lt;code&gt;screen -r&lt;/code&gt; and then close the session with &lt;code&gt;Ctrl + C&lt;/code&gt;. However, if you&amp;rsquo;ve implemented exception handling (like &lt;code&gt;try-except&lt;/code&gt;) in your Python scripts, you&amp;rsquo;ll find that this only breaks out of the loop and doesn&amp;rsquo;t terminate the entire session. In such cases, directly closing a specific session from outside the session is much more convenient.&lt;/p&gt;&#xA;&lt;p&gt;The command to do this is:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;screen -XS test quit&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Here, &lt;code&gt;test&lt;/code&gt; is the name of your session. Of course, to view all active sessions, you can use:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;screen -ls&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Here&amp;rsquo;s an example sequence of commands:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;screen -S test python test.py&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;screen -ls&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;screen -XS test quit&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;screen -ls&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;&lt;img src=&#34;https://www.bobobk.com/wp-content/uploads/2019/05/screen_test.webp&#34; alt=&#34;screen_test&#34;&gt;&lt;/p&gt;</description>
    </item>
  </channel>
</rss>
