ℹ️ Skipped - page is already crawled
| Filter | Status | Condition | Details |
|---|---|---|---|
| HTTP status | PASS | download_http_code = 200 | HTTP 200 |
| Age cutoff | PASS | download_stamp > now() - 6 MONTH | 0.8 months ago |
| History drop | PASS | isNull(history_drop_reason) | No drop reason |
| Spam/ban | PASS | fh_dont_index != 1 AND ml_spam_score = 0 | ml_spam_score=0 |
| Canonical | PASS | meta_canonical IS NULL OR = '' OR = src_unparsed | Not set |
| Property | Value |
|---|---|
| URL | https://superuser.com/questions/603374/how-to-remove-many-detached-screen-sessions-in-unix |
| Last Crawled | 2026-03-19 19:59:34 (24 days ago) |
| First Indexed | 2016-05-09 10:28:22 (9 years ago) |
| HTTP Status Code | 200 |
| Meta Title | linux - How to remove many detached screen sessions in Unix? - Super User |
| Meta Description | null |
| Meta Canonical | null |
| Boilerpipe Text | 2
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?
Ben N
42.7k
17 gold badges
155 silver badges
197 bronze badges
asked
Jun 3, 2013 at 23:48
5
4
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.
answered
Sep 18, 2014 at 10:19
2
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.
answered
Jun 4, 2013 at 17:49
0
2
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 superuser.com
# screen -S superuser.com
.. < Ctrl + a + d > ..
# screen -ls
21668.superuser.com (Detached)
21664.otography.com (Detached)
17386.wimbledon (Detached)
17200.unsigned.com (Detached)
16956.tattooremo (Detached)
1082.refinedwater.co.uk (Detached)
27256.apple.com (Detached)
21481.careus.co.uk (Detached)
326.onlinebuziness.me.uk (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.
answered
Oct 27, 2015 at 5:43
0
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.
answered
Oct 27, 2015 at 19:38
0
I had this issue with a user. I first ran this command to see how many screen sessions were open by that user:
*# ps aux | grep username > /detached_screens.txt**
(The above command will look at the processes that are running and the grep command will help you narrow down the search to only show processes ran by that specific user. After grep username, I had it write to a file for reference. You don't have to use that part)
I found 278 detached screen sessions that had never been closed from previous months. After figuring out the PID for each detached screen, I ran the following command:
*# kill -9 PID PID PID PID PID ...
This killed all the processes I specified.
answered
Dec 29, 2017 at 14:55
You must
log in
to answer this question.
Start asking to get answers
Find the answer to your question by asking.
Ask question
Explore related questions
See similar questions with these tags. |
| Markdown | [Skip to main content](https://superuser.com/questions/603374/how-to-remove-many-detached-screen-sessions-in-unix#content)
#### Stack Exchange Network
Stack Exchange network consists of 183 Q\&A communities including [Stack Overflow](https://stackoverflow.com/), the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.
[Visit Stack Exchange](https://stackexchange.com/)
1. - [Tour Start here for a quick overview of the site](https://superuser.com/tour)
- [Help Center Detailed answers to any questions you might have](https://superuser.com/help)
- [Meta Discuss the workings and policies of this site](https://meta.superuser.com/)
- [About Us Learn more about Stack Overflow the company, and our products](https://stackoverflow.co/)
2. ### [current community](https://superuser.com/)
- [Super User](https://superuser.com/)
[help](https://superuser.com/help) [chat](https://chat.stackexchange.com/?tab=site&host=superuser.com)
- [Meta Super User](https://meta.superuser.com/)
### your communities
[Sign up](https://superuser.com/users/signup?ssrc=site_switcher&returnurl=https%3A%2F%2Fsuperuser.com%2Fquestions%2F603374%2Fhow-to-remove-many-detached-screen-sessions-in-unix) or [log in](https://superuser.com/users/login?ssrc=site_switcher&returnurl=https%3A%2F%2Fsuperuser.com%2Fquestions%2F603374%2Fhow-to-remove-many-detached-screen-sessions-in-unix) to customize your list.
### [more stack exchange communities](https://stackexchange.com/sites)
[company blog](https://stackoverflow.blog/)
3. [Log in](https://superuser.com/users/login?ssrc=head&returnurl=https%3A%2F%2Fsuperuser.com%2Fquestions%2F603374%2Fhow-to-remove-many-detached-screen-sessions-in-unix)
4. [Sign up](https://superuser.com/users/signup?ssrc=head&returnurl=https%3A%2F%2Fsuperuser.com%2Fquestions%2F603374%2Fhow-to-remove-many-detached-screen-sessions-in-unix)
[](https://superuser.com/)
1. 1. [Home](https://superuser.com/)
2. [Questions](https://superuser.com/questions)
3. [Unanswered](https://superuser.com/unanswered)
4. [AI Assist](https://stackoverflow.com/ai-assist)
5. [Tags](https://superuser.com/tags)
6. [Chat](https://chat.stackexchange.com/)
7. [Users](https://superuser.com/users)
8. [Companies](https://stackoverflow.com/jobs/companies?so_medium=superuser&so_source=SiteNav)
2. Stack Internal
Stack Overflow for Teams is now called **Stack Internal**. Bring the best of human thought and AI automation together at your work.
[Try for free](https://stackoverflowteams.com/teams/create/free/?utm_medium=referral&utm_source=superuser-community&utm_campaign=side-bar&utm_content=explore-teams) [Learn more](https://stackoverflow.co/internal/?utm_medium=referral&utm_source=superuser-community&utm_campaign=side-bar&utm_content=explore-teams)
3. [Stack Internal]()
4. Bring the best of human thought and AI automation together at your work. [Learn more](https://stackoverflow.co/internal/?utm_medium=referral&utm_source=superuser-community&utm_campaign=side-bar&utm_content=explore-teams-compact)
**Stack Internal**
Knowledge at work
Bring the best of human thought and AI automation together at your work.
[Explore Stack Internal](https://stackoverflow.co/internal/?utm_medium=referral&utm_source=superuser-community&utm_campaign=side-bar&utm_content=explore-teams-compact-popover)
# [How to remove many detached screen sessions in Unix?](https://superuser.com/questions/603374/how-to-remove-many-detached-screen-sessions-in-unix)
[Ask Question](https://superuser.com/questions/ask)
Asked
12 years, 9 months ago
Modified [8 years, 2 months ago](https://superuser.com/questions/603374/how-to-remove-many-detached-screen-sessions-in-unix?lastactivity "2017-12-29 15:32:13Z")
Viewed 22k times
2
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?
- [linux](https://superuser.com/questions/tagged/linux "show questions tagged 'linux'")
- [unix](https://superuser.com/questions/tagged/unix "show questions tagged 'unix'")
- [gnu-screen](https://superuser.com/questions/tagged/gnu-screen "show questions tagged 'gnu-screen'")
- [solaris](https://superuser.com/questions/tagged/solaris "show questions tagged 'solaris'")
[Share](https://superuser.com/q/603374 "Short permalink to this question")
[Improve this question](https://superuser.com/posts/603374/edit)
Follow
[edited Apr 22, 2016 at 20:23](https://superuser.com/posts/603374/revisions "show all edits to this post")
[](https://superuser.com/users/380318/ben-n)
[Ben N](https://superuser.com/users/380318/ben-n)
42\.7k1717 gold badges155155 silver badges197197 bronze badges
asked Jun 3, 2013 at 23:48
[](https://superuser.com/users/212071/nitin4873)
[Nitin4873](https://superuser.com/users/212071/nitin4873)
18911 gold badge11 silver badge77 bronze badges
5
- 1
Have you considered attaching them, and exiting...? or are you asking for a fast way to kill them all?
demure
– [demure](https://superuser.com/users/222271/demure "6,630 reputation")
2013-06-03 23:58:35 +00:00
Commented Jun 3, 2013 at 23:58
- 2
sounds like this is the same question [stackoverflow.com/questions/1509677/…](http://stackoverflow.com/questions/1509677/kill-detached-screen-session "kill detached screen session")
Hans Meiser
– [Hans Meiser](https://superuser.com/users/228841/hans-meiser "213 reputation")
2013-06-04 00:01:19 +00:00
Commented Jun 4, 2013 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!\!
Nitin4873
– [Nitin4873](https://superuser.com/users/212071/nitin4873 "189 reputation")
2013-06-04 01:09:22 +00:00
Commented Jun 4, 2013 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 ?
Nitin4873
– [Nitin4873](https://superuser.com/users/212071/nitin4873 "189 reputation")
2013-06-04 01:12:03 +00:00
Commented Jun 4, 2013 at 1:12
- @HansMeiser to be fair, that one should probably have been migrated to SU...
Kruug
– [Kruug](https://superuser.com/users/182949/kruug "5,260 reputation")
2013-06-04 17:54:58 +00:00
Commented Jun 4, 2013 at 17:54
[Add a comment](https://superuser.com/questions/603374/how-to-remove-many-detached-screen-sessions-in-unix "Use comments to ask for more information or suggest improvements. Avoid answering questions in comments.") \|
## 5 Answers 5
Sorted by:
[Reset to default](https://superuser.com/questions/603374/how-to-remove-many-detached-screen-sessions-in-unix?answertab=scoredesc#tab-top)
4
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.
```
[Share](https://superuser.com/a/813418 "Short permalink to this answer")
[Improve this answer](https://superuser.com/posts/813418/edit)
Follow
answered Sep 18, 2014 at 10:19
[](https://superuser.com/users/248871/gc-13)
[GC 13](https://superuser.com/users/248871/gc-13)
33333 silver badges1212 bronze badges
[Add a comment](https://superuser.com/questions/603374/how-to-remove-many-detached-screen-sessions-in-unix "Use comments to ask for more information or suggest improvements. Avoid comments like “+1” or “thanks”.") \|
2
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](https://superuser.com/a/603691 "Short permalink to this answer")
[Improve this answer](https://superuser.com/posts/603691/edit)
Follow
answered Jun 4, 2013 at 17:49
[](https://superuser.com/users/215301/philip-kearns)
[Philip Kearns](https://superuser.com/users/215301/philip-kearns)
1,10477 silver badges1212 bronze badges
0
[Add a comment](https://superuser.com/questions/603374/how-to-remove-many-detached-screen-sessions-in-unix "Use comments to ask for more information or suggest improvements. Avoid comments like “+1” or “thanks”.") \|
2
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 superuser.com
# screen -S superuser.com
.. < Ctrl + a + d > ..
# screen -ls
21668.superuser.com (Detached)
21664.otography.com (Detached)
17386.wimbledon (Detached)
17200.unsigned.com (Detached)
16956.tattooremo (Detached)
1082.refinedwater.co.uk (Detached)
27256.apple.com (Detached)
21481.careus.co.uk (Detached)
326.onlinebuziness.me.uk (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](https://superuser.com/a/992281 "Short permalink to this answer")
[Improve this answer](https://superuser.com/posts/992281/edit)
Follow
answered Oct 27, 2015 at 5:43
[](https://superuser.com/users/356011/sherpaurgen)
[sherpaurgen](https://superuser.com/users/356011/sherpaurgen)
17311 silver badge1313 bronze badges
[Add a comment](https://superuser.com/questions/603374/how-to-remove-many-detached-screen-sessions-in-unix "Use comments to ask for more information or suggest improvements. Avoid comments like “+1” or “thanks”.") \|
0
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](https://superuser.com/a/992620 "Short permalink to this answer")
[Improve this answer](https://superuser.com/posts/992620/edit)
Follow
answered Oct 27, 2015 at 19:38
[](https://superuser.com/users/514766/abdurrahim-y%C4%B1ld%C4%B1r%C4%B1m)
[Abdurrahim Yıldırım](https://superuser.com/users/514766/abdurrahim-y%C4%B1ld%C4%B1r%C4%B1m)
1
[Add a comment](https://superuser.com/questions/603374/how-to-remove-many-detached-screen-sessions-in-unix "Use comments to ask for more information or suggest improvements. Avoid comments like “+1” or “thanks”.") \|
0
I had this issue with a user. I first ran this command to see how many screen sessions were open by that user:
```
*# ps aux | grep username > /detached_screens.txt**
```
(The above command will look at the processes that are running and the grep command will help you narrow down the search to only show processes ran by that specific user. After grep username, I had it write to a file for reference. You don't have to use that part) I found 278 detached screen sessions that had never been closed from previous months. After figuring out the PID for each detached screen, I ran the following command:
```
*# kill -9 PID PID PID PID PID ...
```
This killed all the processes I specified.
[Share](https://superuser.com/a/1280946 "Short permalink to this answer")
[Improve this answer](https://superuser.com/posts/1280946/edit)
Follow
[edited Dec 29, 2017 at 15:32](https://superuser.com/posts/1280946/revisions "show all edits to this post")
[](https://superuser.com/users/213131/i-say-reinstate-monica)
[I say Reinstate Monica](https://superuser.com/users/213131/i-say-reinstate-monica)
26\.8k2121 gold badges103103 silver badges138138 bronze badges
answered Dec 29, 2017 at 14:55
[](https://superuser.com/users/857301/mastershake36)
[MasterShake36](https://superuser.com/users/857301/mastershake36)
1
[Add a comment](https://superuser.com/questions/603374/how-to-remove-many-detached-screen-sessions-in-unix "Use comments to ask for more information or suggest improvements. Avoid comments like “+1” or “thanks”.") \|
## You must [log in](https://superuser.com/users/login?ssrc=question_page&returnurl=https%3A%2F%2Fsuperuser.com%2Fquestions%2F603374) to answer this question.
Start asking to get answers
Find the answer to your question by asking.
[Ask question](https://superuser.com/questions/ask)
Explore related questions
- [linux](https://superuser.com/questions/tagged/linux "show questions tagged 'linux'")
- [unix](https://superuser.com/questions/tagged/unix "show questions tagged 'unix'")
- [gnu-screen](https://superuser.com/questions/tagged/gnu-screen "show questions tagged 'gnu-screen'")
- [solaris](https://superuser.com/questions/tagged/solaris "show questions tagged 'solaris'")
See similar questions with these tags.
- The Overflow Blog
- [Keeping the lights on for open source](https://stackoverflow.blog/2026/03/17/keeping-the-lights-on-for-open-source/)
- [AI is becoming a second brain at the expense of your first one](https://stackoverflow.blog/2026/03/19/ai-is-becoming-a-second-brain-at-the-expense-of-your-first-one/)
- Featured on Meta
- [Logo updates to Stack Overflow's visual identity](https://meta.stackexchange.com/questions/417394/logo-updates-to-stack-overflows-visual-identity)
#### Related
[25](https://superuser.com/questions/58525/how-do-i-reconnect-to-a-lost-screen-detached-missing-socket "Question score (upvotes - downvotes)")
[How do I reconnect to a lost screen (detached, missing socket)?](https://superuser.com/questions/58525/how-do-i-reconnect-to-a-lost-screen-detached-missing-socket)
[3](https://superuser.com/questions/154724/centos-screen-command-detached-process "Question score (upvotes - downvotes)")
[centos Screen - command detached process](https://superuser.com/questions/154724/centos-screen-command-detached-process)
[112](https://superuser.com/questions/243459/unix-how-to-unsplit-in-screen "Question score (upvotes - downvotes)")
[Unix: How to unsplit in screen](https://superuser.com/questions/243459/unix-how-to-unsplit-in-screen)
[5](https://superuser.com/questions/347595/linux-screen-command-lowers-process-priority-if-detached "Question score (upvotes - downvotes)")
[linux 'screen' command - lowers process priority if detached?](https://superuser.com/questions/347595/linux-screen-command-lowers-process-priority-if-detached)
[2](https://superuser.com/questions/469578/send-command-to-a-detached-screen-with-enter "Question score (upvotes - downvotes)")
[Send command to a detached screen with enter?](https://superuser.com/questions/469578/send-command-to-a-detached-screen-with-enter)
[0](https://superuser.com/questions/683967/pause-ssh-session "Question score (upvotes - downvotes)")
[Pause SSH Session](https://superuser.com/questions/683967/pause-ssh-session)
[5](https://superuser.com/questions/833081/get-command-output-from-detached-screen "Question score (upvotes - downvotes)")
[Get command output from detached screen](https://superuser.com/questions/833081/get-command-output-from-detached-screen)
[1](https://superuser.com/questions/1332694/use-bashrc-in-a-detached-screen "Question score (upvotes - downvotes)")
[Use .bashrc in a detached screen](https://superuser.com/questions/1332694/use-bashrc-in-a-detached-screen)
#### [Hot Network Questions](https://stackexchange.com/questions?tab=hot)
- [What is the history of name changes for D\&D 5.5e / D\&D 2024?](https://rpg.stackexchange.com/questions/218950/what-is-the-history-of-name-changes-for-dd-5-5e-dd-2024)
- [Caching twice: any regular cache mechanism + HttpContext.Items on top of that](https://softwareengineering.stackexchange.com/questions/460998/caching-twice-any-regular-cache-mechanism-httpcontext-items-on-top-of-that)
- [What is the evaluation order of sign and unit in physical quantities?](https://physics.stackexchange.com/questions/870190/what-is-the-evaluation-order-of-sign-and-unit-in-physical-quantities)
- [How to reconcile 2 Corinthians 5:10 with God “remembering sins no more”?](https://hermeneutics.stackexchange.com/questions/115380/how-to-reconcile-2-corinthians-510-with-god-remembering-sins-no-more)
- [How to replace the battery for a prop/costume doctor who (11th) sonic screwdriver](https://scifi.stackexchange.com/questions/303723/how-to-replace-the-battery-for-a-prop-costume-doctor-who-11th-sonic-screwdrive)
- [How to avoid glitches when using Trim Curve in Geometry Nodes to trim start of a curve?](https://blender.stackexchange.com/questions/345749/how-to-avoid-glitches-when-using-trim-curve-in-geometry-nodes-to-trim-start-of-a)
- [Extra Part tags in accessible, tagged PDF](https://tex.stackexchange.com/questions/761030/extra-part-tags-in-accessible-tagged-pdf)
- [How do physicalists explain rational oughts?](https://philosophy.stackexchange.com/questions/137158/how-do-physicalists-explain-rational-oughts)
- [Can the path of an ejected device be validated?](https://unix.stackexchange.com/questions/805048/can-the-path-of-an-ejected-device-be-validated)
- [If two elements are trace equivalent in a surface group are they trace equivalent in a free group?](https://mathoverflow.net/questions/509214/if-two-elements-are-trace-equivalent-in-a-surface-group-are-they-trace-equivalen)
- [Are there Latinate ordinal numbers after 12? and if not, why don't they exist?](https://english.stackexchange.com/questions/639252/are-there-latinate-ordinal-numbers-after-12-and-if-not-why-dont-they-exist)
- [What does 在 mean in "在没证明自己前"](https://chinese.stackexchange.com/questions/64003/what-does-%E5%9C%A8-mean-in-%E5%9C%A8%E6%B2%A1%E8%AF%81%E6%98%8E%E8%87%AA%E5%B7%B1%E5%89%8D)
- [Strange anime with supernatural elements about a boy moving to a town and meeting a weird girl?](https://movies.stackexchange.com/questions/131599/strange-anime-with-supernatural-elements-about-a-boy-moving-to-a-town-and-meetin)
- [Trying to find poem by POC quoting "Walk on the wild side"](https://literature.stackexchange.com/questions/31787/trying-to-find-poem-by-poc-quoting-walk-on-the-wild-side)
- [Why Was the Ark of the Covenant at Bethel instead of Shiloh in Judges 20?](https://hermeneutics.stackexchange.com/questions/115393/why-was-the-ark-of-the-covenant-at-bethel-instead-of-shiloh-in-judges-20)
- [What are the downsides with using an SD card for primary storage on a x86 laptop?](https://superuser.com/questions/1935919/what-are-the-downsides-with-using-an-sd-card-for-primary-storage-on-a-x86-laptop)
- [Why doesn't Earth's atmosphere glow?](https://physics.stackexchange.com/questions/870292/why-doesnt-earths-atmosphere-glow)
- [Why aren't Gazans offered safe passage to Egypt or other countries who can be financially supported to take them?](https://politics.stackexchange.com/questions/94398/why-arent-gazans-offered-safe-passage-to-egypt-or-other-countries-who-can-be-fi)
- [Short story, maybe by Stephen King, about a woman who learns that her boyfriend (husband?) has been manipulating reality to get her](https://scifi.stackexchange.com/questions/303731/short-story-maybe-by-stephen-king-about-a-woman-who-learns-that-her-boyfriend)
- [What is this 1NT rebid response from Bridge Base?](https://boardgames.stackexchange.com/questions/64430/what-is-this-1nt-rebid-response-from-bridge-base)
- [Survival analysis options for nested cancer data](https://stats.stackexchange.com/questions/675226/survival-analysis-options-for-nested-cancer-data)
- [Steampunk lightbulb without electricity](https://worldbuilding.stackexchange.com/questions/272922/steampunk-lightbulb-without-electricity)
- [Creating a Bar Graph using float values from a CSV file](https://blender.stackexchange.com/questions/345731/creating-a-bar-graph-using-float-values-from-a-csv-file)
- [Supplier demands more money to fulfil an order already paid for](https://law.stackexchange.com/questions/114405/supplier-demands-more-money-to-fulfil-an-order-already-paid-for)
[more hot questions](https://superuser.com/questions/603374/how-to-remove-many-detached-screen-sessions-in-unix)
[Question feed](https://superuser.com/feeds/question/603374 "Feed of this question and its answers")
# Subscribe to RSS
Question feed
To subscribe to this RSS feed, copy and paste this URL into your RSS reader.

##### [Super User](https://superuser.com/)
- [Tour](https://superuser.com/tour)
- [Help](https://superuser.com/help)
- [Chat](https://chat.stackexchange.com/?tab=site&host=superuser.com)
- [Contact](https://superuser.com/contact)
- [Feedback](https://meta.superuser.com/)
##### [Company](https://stackoverflow.co/)
- [Stack Overflow](https://stackoverflow.com/)
- [Stack Internal](https://stackoverflow.co/internal/)
- [Stack Data Licensing](https://stackoverflow.co/data-licensing/)
- [Stack Ads](https://stackoverflow.co/advertising/)
- [About](https://stackoverflow.co/)
- [Press](https://stackoverflow.co/company/press/)
- [Legal](https://stackoverflow.com/legal)
- [Privacy Policy](https://stackoverflow.com/legal/privacy-policy)
- [Terms of Service](https://stackoverflow.com/legal/terms-of-service/public)
- Cookie Settings
- [Cookie Policy](https://policies.stackoverflow.co/stack-overflow/cookie-policy)
##### [Stack Exchange Network](https://stackexchange.com/)
- [Technology](https://stackexchange.com/sites#technology)
- [Culture & recreation](https://stackexchange.com/sites#culturerecreation)
- [Life & arts](https://stackexchange.com/sites#lifearts)
- [Science](https://stackexchange.com/sites#science)
- [Professional](https://stackexchange.com/sites#professional)
- [Business](https://stackexchange.com/sites#business)
- [API](https://api.stackexchange.com/)
- [Data](https://data.stackexchange.com/)
- [Blog](https://stackoverflow.blog/?blb=1)
- [Facebook](https://www.facebook.com/officialstackoverflow/)
- [Twitter](https://twitter.com/stackoverflow)
- [LinkedIn](https://linkedin.com/company/stack-overflow)
- [Instagram](https://www.instagram.com/thestackoverflow)
Site design / logo © 2026 Stack Exchange Inc; user contributions licensed under [CC BY-SA](https://stackoverflow.com/help/licensing) . rev 2026.3.19.41259 |
| Readable Markdown | 2
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?
[](https://superuser.com/users/380318/ben-n)
[Ben N](https://superuser.com/users/380318/ben-n)
42\.7k17 gold badges155 silver badges197 bronze badges
asked Jun 3, 2013 at 23:48
[](https://superuser.com/users/212071/nitin4873)
5
4
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.
```
answered Sep 18, 2014 at 10:19
[](https://superuser.com/users/248871/gc-13)
2
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.
answered Jun 4, 2013 at 17:49
[](https://superuser.com/users/215301/philip-kearns)
0
2
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 superuser.com
# screen -S superuser.com
.. < Ctrl + a + d > ..
# screen -ls
21668.superuser.com (Detached)
21664.otography.com (Detached)
17386.wimbledon (Detached)
17200.unsigned.com (Detached)
16956.tattooremo (Detached)
1082.refinedwater.co.uk (Detached)
27256.apple.com (Detached)
21481.careus.co.uk (Detached)
326.onlinebuziness.me.uk (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.
```
answered Oct 27, 2015 at 5:43
[](https://superuser.com/users/356011/sherpaurgen)
0
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.
```
answered Oct 27, 2015 at 19:38
[](https://superuser.com/users/514766/abdurrahim-y%C4%B1ld%C4%B1r%C4%B1m)
0
I had this issue with a user. I first ran this command to see how many screen sessions were open by that user:
```
*# ps aux | grep username > /detached_screens.txt**
```
(The above command will look at the processes that are running and the grep command will help you narrow down the search to only show processes ran by that specific user. After grep username, I had it write to a file for reference. You don't have to use that part) I found 278 detached screen sessions that had never been closed from previous months. After figuring out the PID for each detached screen, I ran the following command:
```
*# kill -9 PID PID PID PID PID ...
```
This killed all the processes I specified.
[](https://superuser.com/users/213131/i-say-reinstate-monica)
answered Dec 29, 2017 at 14:55
[](https://superuser.com/users/857301/mastershake36)
## You must [log in](https://superuser.com/users/login?ssrc=question_page&returnurl=https%3A%2F%2Fsuperuser.com%2Fquestions%2F603374) to answer this question.
Start asking to get answers
Find the answer to your question by asking.
[Ask question](https://superuser.com/questions/ask)
Explore related questions
See similar questions with these tags. |
| Shard | 122 (laksa) |
| Root Hash | 3131140398176769522 |
| Unparsed URL | com,superuser!/questions/603374/how-to-remove-many-detached-screen-sessions-in-unix s443 |