Reputation: 2120
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.
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.
Upvotes: 78
Views: 182440
Reputation: 93
You can simply follow this procedure
If the screen is in detached state
screen -r "screenName"
exit
this will kill/ terminate the screen which you want to kill
If the screen is in attached state
screen -d -r "screenName"
exit
Upvotes: 1
Reputation: 33147
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
Upvotes: 3
Reputation: 1009
From Screen User's Manual ;
screen -d -r "screenName"
Reattach a session and if necessary detach it first
Upvotes: 6
Reputation: 3671
None of the screen
commands were killing or reattaching the screen for me. Any screen
command would just hang. I found another approach.
Each running screen has a file associated with it in:
/var/run/screen/S-{user_name}
The files in that folder will match the names of the screens when running the screen -list
. If you delete the file, it kills the associated running screen (detached or attached).
Upvotes: 0
Reputation: 51
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]
or
sudo kill [sessionId]
Upvotes: 0
Reputation: 309
Suppose your screen id has a pattern. Then you can use the following code to kill all the attached screen at once.
result=$(screen -ls | grep 'pattern_of_screen_id' -o)
for i in $result;
do
`screen -X -S $i quit`;
done
Upvotes: 1
Reputation: 101
This worked for me very well. Get the screen id via:
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
Upvotes: 7
Reputation: 30
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.
Upvotes: -2
Reputation: 247
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.
Upvotes: 22
Reputation: 1172
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
when listed, select with your mouse the session you are interested in and paste it. like this
screen -r
Upvotes: 1
Reputation: 26156
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
Upvotes: 134
Reputation: 10694
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>
Upvotes: 1