在 Linux 中杀死附加屏幕
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/14806051/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Kill Attached Screen in Linux
提问by Slowcoder
I created a screen "myscreen" in linux and it stopped responding abruptly. I closed the terminal and tried to reopen it. "screen -ls" shows that the screen is Attached. I tried the following commands but nothing responds.
我在 linux 中创建了一个屏幕“myscreen”,它突然停止响应。我关闭了终端并试图重新打开它。“screen -ls”显示屏幕已附加。我尝试了以下命令,但没有任何反应。
screen -r myscreen
screen -D myscreen
screen -D -RR myscreen
screen -X -S myscreen quit
Any help to reattach to the screen or to kill the screen is very much appreciated.
非常感谢任何重新连接到屏幕或杀死屏幕的帮助。
采纳答案by Desta Haileselassie Hagos
screen -X -S SCREENID kill
alternatively, you can use the following command
或者,您可以使用以下命令
screen -S SCREENNAME -p 0 -X quit
You can view the list of the screen sessions by executing screen -ls
您可以通过执行查看屏幕会话列表 screen -ls
回答by Hutch
i usually don't name my screen instances, so this might not be useful, but did you try screen -r
without the 'myscreen' part? usually for me, screen -r
will show the PIDs of each screen then i can reattach with screen -d -r <PID>
我通常不命名我的屏幕实例,所以这可能没有用,但是您是否尝试过screen -r
没有“myscreen”部分?通常对我来说,screen -r
会显示每个屏幕的 PID 然后我可以重新附加screen -d -r <PID>
回答by andreskwan
You could create a function to kill all existing sessions. take a look at Kill all detached screen sessions
您可以创建一个函数来终止所有现有会话。看看杀死所有分离的屏幕会话
to list all active sessions use screen -r
列出所有活动会话使用 screen -r
when listed, select with your mouse the session you are interested in and paste it. like this
列出后,用鼠标选择您感兴趣的会话并粘贴它。像这样
screen -r
屏幕 -r
回答by naveen nani
Create screen from Terminal:
从终端创建屏幕:
screen -S <screen_name>
To see list of screens:
要查看屏幕列表:
<screen -ls> or <screen -list>
To go to particular screen:
转到特定屏幕:
<screen -x screen_name>
<screen -r screen_name>
Inside screen
内屏
To Terminate screen:
终止屏幕:
give ctrl+d screen will get terminated
To Detach screen:
分离屏幕:
give <ctrl+ad>or <screen -d >screen will get detached
To reattach screen:
重新连接屏幕:
screen -x <screen_name> or screen -r <screen_name>
To kill a screen from Terminal:
从终端杀死屏幕:
<screen -X -S screen_name quit>
or
或者
<screen -X -S screen_name kill>
You can use screen_name or process_id to execute commands.
您可以使用 screen_name 或 process_id 来执行命令。
回答by HuyLe
For result find: Click Here
查询结果:点击这里
Screen is a full-screen window manager that multiplexes a physical terminal between several processes, typically interactive shells. There is a scrollback history buffer for each virtual terminal and a copy-and-paste mechanism that allows the user to move text regions between windows.
Screen 是一个全屏窗口管理器,它在多个进程之间多路复用一个物理终端,通常是交互式 shell。每个虚拟终端都有一个回滚历史缓冲区和一个允许用户在窗口之间移动文本区域的复制和粘贴机制。
回答by TheWiz
This worked for me very well. Get the screen id via:
这对我非常有效。通过以下方式获取屏幕 ID:
screen -r
or
或者
screen -ls
then kill the screen: kill -9 <screenID>
it now becomes a dead screen,
then wipe it out with: screen -wipe
然后杀死屏幕:kill -9 <screenID>
它现在变成一个死屏幕,然后用以下方法将其擦除:screen -wipe
回答by Md Kauser Ahmmed
Suppose your screen id has a pattern. Then you can use the following code to kill all the attached screen at once.
假设您的屏幕 ID 有一个模式。然后您可以使用以下代码一次杀死所有附加的屏幕。
result=$(screen -ls | grep 'pattern_of_screen_id' -o)
for i in $result;
do
`screen -X -S $i quit`;
done
回答by Siddhant
You can find the process id of the attached running screen.
I found it same as the session id which you can get by command:screen -ls
And you can use following command to kill that process:kill [sessionId]
orsudo kill [sessionId]
您可以找到附加运行屏幕的进程 ID。我发现它与您可以通过命令获取的会话 ID 相同:screen -ls
您可以使用以下命令来终止该进程:kill [sessionId]
或sudo kill [sessionId]
回答by seralouk
To kill a detached screen use this from the terminal:
要杀死分离的屏幕,请从终端使用它:
screen -X -S "SCEEN_NAME" quit
If you are attached, then use (from the terminal and inside the screen):
如果您已连接,则使用(从终端和屏幕内部):
exit