Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Kill all detached screen sessions

Tags:

gnu-screen

When I execute screen -ls, I see the following. How can I kill all the detached sessions?

There are screens on:

    84918.ttys002.ros-mbp   (Detached)      84944.ttys008.ros-mbp   (Detached)      84970.ttys013.ros-mbp   (Attached)      84998.ttys002.ros-mbp   (Detached)      85024.ttys002.ros-mbp   (Detached)  

5 Sockets in /var/folders/86/062qtcyx2rxbnmn8mtpkyghs0r0r_z/T/.screen.

like image 253
Rose Perrone Avatar asked Jan 21 '13 21:01

Rose Perrone


People also ask

How do you kill a detached screen session?

Leaving Screen Terminal Session There are 2 (two) ways to leaving the screen. First, we are using “Ctrl-A” and “d” to detach the screen. Second, we can use the exit command to terminating the screen. You also can use “Ctrl-A” and “K” to kill the screen.

How do I kill all detached screens in Linux?

To run it, call killd . This will kill all screen sessions, detached or not.

How do I detach all screen sessions?

To detach it, type Ctrl-a Ctrl-d (most commands in screen start with Ctrl-a, this overrides the Ctrl-a command normally used when you want to jump to the start of a line). To reconnect to it, type 'screen -r'.


1 Answers

screen -ls | grep pts | cut -d. -f1 | awk '{print $1}' | xargs kill

Kill only Detached screen sessions (credit @schatten):

screen -ls | grep Detached | cut -d. -f1 | awk '{print $1}' | xargs kill

like image 116
Milind Shah Avatar answered Oct 06 '22 09:10

Milind Shah