春江暮客

春江暮客的个人学习分享网站

Closing a Screen Session from Outside the Session

2019-05-21 Miscellaneous

Screen is an excellent tool for running programs in the background. Typically, you can connect to a session using screen -r and then close the session with Ctrl + C. However, if you’ve implemented exception handling (like try-except) in your Python scripts, you’ll find that this only breaks out of the loop and doesn’t terminate the entire session. In such cases, directly closing a specific session from outside the session is much more convenient.

The command to do this is:

screen -XS test quit

Here, test is the name of your session. Of course, to view all active sessions, you can use:

screen -ls

Here’s an example sequence of commands:

screen -S test python test.py
screen -ls
screen -XS test quit
screen -ls

screen_test

友情链接

其它