maolingzhi
maolingzhi

Reputation: 691

How would you let screen or byobu kill all detached sessions?

I don't want them any more.

I tried screen --help and didn't find some command suite for this task.

Is there some way to solve this problem?

Upvotes: 3

Views: 4279

Answers (2)

Rose Perrone
Rose Perrone

Reputation: 63576

Include this function in your .bash_profile:

killd () {
echo yo
for session in $(screen -ls | grep -o '[0-9]\{5\}')
do
screen -S "${session}" -X quit;
done
}

to run it, call killd

Upvotes: 0

Dustin Kirkland
Dustin Kirkland

Reputation: 5483

You'd need to loop over each detached screen session and issue the "quit" command. The following one-liner would do it for you:

screen -ls | grep "Detached" | awk '{print $1}' | xargs -i screen -X -S {} quit

Upvotes: 8

Related Questions