2

I have a lot of screens on my server. With screen -ls I get:

 There are screens on:
    12858.test1 (Detached)
    28210.test2 (Detached)
    12494.moretesting3  (Detached)
    31787.testingfour4  (Detached)
    13192.testscreen5   (Detached)
5 Sockets in /var/run/screen/S-root.

I know I can quit an individual screen with screen -S 12858 -X quit or screen -S test1 -X quit but I need a way to close all the screens at the same time.

Is there an ssh command or bash script that is able to close every open/detached screen?

Runner
  • 23
  • 4

2 Answers2

7

Would a simple killall screen suffice?

Sven
  • 98,649
  • 14
  • 180
  • 226
  • 5
    ...as long as you're not on a system where `killall` is the SysV style tool that literally kills *all* processes you can kill. (Of course as long as you're not root this will probably have the desired effect - all your screen sessions will be gone :-) – voretaq7 May 27 '13 at 03:22
  • What if you are root? Is there anything else that would work? – Runner May 28 '13 at 21:52
  • You can also do `kill \`pidof screen\`` – Falcon Momot Jun 19 '13 at 05:33
-2

For that very reason, I recommend using byobu. It's in most Linux Distros' repo's, and it is much easier to have multiple screens open at once and see them all at a glance.

senorsmile
  • 713
  • 8
  • 20
  • This doesn't answer the question. He's asking about how to easily kill off a bunch of detached screen sessions, not about how to have multiple screens open. – EEAA Jun 19 '13 at 03:57
  • But, using byobu makes this very easy since it will show if you on login if existing / multiple sessions are open, and allow you to kill any/all of them. – senorsmile Jul 01 '13 at 22:43