Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a script and use the following command in it:

screen -dmS name bash -c "ls -1 > out"

What I am trying to achieve is to create a screen session, run a command and detach from it. The command above is working fine, except for the screen session which is being terminated:

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

Why the session is not saved despite on the -dm parameters?

share|improve this question
What would you expect the (detached) screen to contain, given that the command you feed it runs once, and then exists? To compare, trying doing the same but by starting something interactive, like a text editor. – andol Jan 8 '12 at 17:50
You're right. It's working with interactive commands like 'vi'. Is there any possibility to keep the screen session detached while running a non-interactive command? – Andrew Jan 8 '12 at 18:14
May I ask what you are trying to accomplish? What use would you have of being able to reattach a screen where that command had been run? – andol Jan 8 '12 at 18:21
Add "zombie cr" to your .screenrc file - it'll keep windows around when the child process has exited unless you press "r" or "c". – Steve Kemp Jan 8 '12 at 18:36
Yes, 'zombie cr' helped. Please post it as a reply and I will accept it as a solution. – Andrew Jan 8 '12 at 19:07
up vote 1 down vote accepted

Add to your ~/.screenrc file :

 zombie cr

That setting will keep any internal screen windows open when the child process has exited.

You then press "c" or "r" to clear or resurrect the screen. You can see further details on the zombie setting if you run "man screen"

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.