Sign up ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I have been working in different screen sessions in past projects , hence have a few screen sessions accumulated. Now i have been asked to remove excess/unrequired screen sessions from the unix box.

one of the method that came to my mind is to delete the folder where screens are kept in the /tmp/mylogin/screen-r/... folder , but am not sure iff that would leave any unintentional process or something passive on the server

any idea how can i remove them without leaving any unknown dangling things around in the server ?

also i wanted to ask do these detached screens occupy quite a bit of resource , enough to alert the sys admin ie any issue with having a few unused/detached screen sessions around ?

PS : none of them are dead sessions , status is detached not dead. the OS is solaris

share|improve this question
Have you considered attaching them, and exiting...? or are you asking for a fast way to kill them all? – demure Jun 3 '13 at 23:58
sounds like this is the same question… – Hans Meiser Jun 4 '13 at 0:01
@demure i dont use them now , i made a new one for each project and now have quite a few .......... just thinking of ways to get rid of them or at least reduce them!! – nsd Jun 4 '13 at 1:09
@HansMeiser ....... thanks , i did search for it , but didnt find anything here. I didnt look in SO. Any way to close this question or should i just delete this ? – nsd Jun 4 '13 at 1:12
@HansMeiser to be fair, that one should probably have been migrated to SU... – Kruug Jun 4 '13 at 17:54

4 Answers 4

How about something like this:

screen -ls | awk -F. '$NF~"(Attached)" {print "kill -HUP " $1}' | sh

Leave out the | sh if you want to see what it's going to execute.

It seems to work fine in a quick test I did.

share|improve this answer
Thanks , +1 for the answer . – nsd Jun 4 '13 at 19:05

List show similar to below output

rajshah@rainbow:~$ screen -ls

There are screens on:
        8105.pts-152.rainbow    (Detached)     (Attached)
        20462.rajshah       (Attached) 3 Sockets in /var/run/screen/S-rajshah.

As screen sessions are stored in /var/run/screen/S-/

To remove any session,

rm -rf /var/run/screen/S-rajshah/8105.pts-152.rainbow

rajshah@rainbow:~$ screen -ls

There are screens on:     (Attached)
        20462.rajshah       (Attached) 3 Sockets in /var/run/screen/S-rajshah.
share|improve this answer

I know its old question but Here is what i did

Named sessions : when i open screen to have meaningful name id for some stuffs im doing related to 
# screen -S
.. < Ctrl + a + d > ..
# screen -ls (Detached) (Detached)
    17386.wimbledon (Detached)  (Detached)
    16956.tattooremo    (Detached) (Detached) (Detached)  (Detached)    (Detached)

# screen -ls | grep "Detached" | awk '{ print $1; }' | cut -d'.' -f2- | xargs -I {} -n 1 screen -S {} -X quit

# screen -ls
    No Sockets found in /var/run/screen/S-root.

Normal session names : when I just type "screen" to openup screen session

 #screen -ls
    There are screens on:
    11580.pts-0.server  (Detached)
    11571.pts-0.server  (Detached)
    2 Sockets in /var/run/screen/S-root.

# screen -ls | grep "Detached" | awk '{ print $1; }' | cut -d'.' -f1 | xargs -I {} -n 1 screen -S {} -X quit

# screen -ls
No Sockets found in /var/run/screen/S-root.
share|improve this answer

I think the secure way is first kill screen process then run screen command with the option I added.

#ps  -ef|grep screen|grep  -v  grep 

root  8362     1   0 21:20:38 ?           0:00 screen

# screen -ls
There are screens on:
        8363.pts-19.   (Dead ???)
        8262.8  (Attached)
Remove dead screens with 'screen -wipe'.
2 Sockets in /root/.screen.

#kill -9 8262

# screen -wipe
There are screens on:
        8362.pts-19   (Removed)
        8263.8  (Removed)
2 sockets wiped out.
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.