Unix & Linux: How do I kill all screens? (7 Solutions!!)

Опубликовано: 08 Август 2020
на канале: Roel Van de Paar
114
1

Unix & Linux: How do I kill all screens?


The Question: I accidentally created over 1000 screens. How do I kill them all with one
command? (Or a few)

Solutions: Please watch the whole video to see all solutions, in order of how many people found them helpful

== This solution helped 114 people ==
You can use :
pkill screen
Or
killall screen
----
In OSX the process is called SCREEN in all caps. So, use:
pkill SCREEN
Or
killall SCREEN

== This solution helped 2 people ==
I'm a bit puzzled over how you managed to create 1000 "screens". Did you
perhaps mean 1000 screen windows (1000 different terminal windows within a
single screen session)?
If you meant 1000 windows within a single screen session, then a more elegant
solution would be to quit screen using the command C-a (ctrl-a followed by ).

== This solution helped 16 people ==
If the screens are dead, use:
screen -wipe

== This solution helped 6 people ==
str=$(screen -ls)

array=$(echo $str|tr "." "n")

for V in $array
do
if [ $V -gt 0 ]
then screen -S $V -X quit
fi
done

== This solution helped 9 people ==
Have recently begun to familiarize myself with awk I put together this and it
served its purpose. I posted it since its quite easy to understand.
screen -ls | grep '(Detached)' | awk 'sys {screen -S $1 -X quit}'
Where screen -ls lists all current screens. grep 'pattern' filters out all
matching rows. We can then get a handle for all detached screens and with awk
sys {command} we can copy and paste together a command and execute it with sys,
$1 refers to the first argument picked up by awk. Finally we execute the quit
command with screen -X quit.

== This solution helped 1 person ==
The following command will terminate all inactive screens:
perl -e 'while (map { kill 9, [split /./]->[0] } grep { /Detached/ } split /n/,
qx{screen -ls}) { sleep 1 } exec qw(screen -wipe)'

With thanks & praise to God, and with thanks to the many people who have made this project possible! | Content (except music & images) licensed under cc by-sa 3.0 | Music: https://www.bensound.com/royalty-free... | Images: https://stocksnap.io/license & others | With thanks to user user370823 (https://unix.stackexchange.com/users/..., user Stephen Rauch (https://unix.stackexchange.com/users/..., user Railgun2 (https://unix.stackexchange.com/users/..., user Rahul Patil (https://unix.stackexchange.com/users/..., user Michael Vu (https://unix.stackexchange.com/users/..., user Kevdog777 (https://unix.stackexchange.com/users/..., user Jeff Schaller (https://unix.stackexchange.com/users/..., user Eliassen (https://unix.stackexchange.com/users/..., user Don Wei (https://unix.stackexchange.com/users/..., user BrainStone (https://unix.stackexchange.com/users/..., user Archemar (https://unix.stackexchange.com/users/..., user Adam_G (https://unix.stackexchange.com/users/..., and the Stack Exchange Network (http://unix.stackexchange.com/questio.... Trademarks are property of their respective owners. Disclaimer: All information is provided "AS IS" without warranty of any kind. You are responsible for your own actions. Please contact me if anything is amiss at Roel D.OT VandePaar A.T gmail.com.