Linux – How to remove many detached screen sessions in Unix

gnu-screenlinuxsolarisunix

I have been working in different screen sessions in past projects, so I have a few screen sessions accumulated. Now I have been asked to remove excess/unnecessary screen sessions from the Unix box. None of them are dead sessions – the status is detached, not dead. The OS is Solaris.

One of the methods 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 if that would leave any extra processes or something passive on the server.

How can I remove them without leaving anything behind?

Also, do these detached screens occupy quite a bit of resources, enough to alert the sysadmin? That is, are there actually any issues created by having a few unused/detached screen sessions around?

Best Answer

List show similar to below output

rajshah@rainbow:~$ screen -ls

There are screens on:
        8105.pts-152.rainbow    (Detached)
        5587.work     (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:
        5587.work     (Attached)
        20462.rajshah       (Attached) 3 Sockets in /var/run/screen/S-rajshah.
Related Question