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.
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.
To run it, call killd . This will kill all screen sessions, detached or not.
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'.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With