Closing a Screen Session from Outside the Session
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
- 原文作者:春江暮客
- 原文链接:https://www.bobobk.com/en/310.html
- 版权声明:本作品采用知识共享署名-非商业性使用-禁止演绎 4.0 国际许可协议进行许可,非商业转载请注明出处(作者,原文链接),商业转载请联系作者获得授权。