Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

When running 'screen ls' the screen stops with the text [screen is terminating]. I would like screen to keep the session alive and reattach to it to see the output of ls.

Of course the real thing is that I don't run screen ls, but rather a screen fsck ..., so I would like to ensure that the screen is not terminating when this command is finished.

I would love to have an answer that is useful for an already existing running screen session, so some interactive keys like C-a ... or C-a : (Enter command line mode)

share|improve this question
add comment

2 Answers

up vote 5 down vote accepted

You can enter the zombie kr command after typing Ctrl-A:, to make a running screen keep the window open after the command finishes. The kr part is specifying what keys you want to use to control the window after its command has finished -- in this case, "k" to kill/close the window, or "r" to restart the command.

share|improve this answer
    
+1 for clarification that you could do this on the fly without editing your .screenrc. –  Phil Hollenback Feb 20 '11 at 8:53
    
Thanks, this was exactly what I was looking for... –  Jarl Mar 1 '11 at 22:48
add comment

Can't you just start screen first and run fsck inside your screen session?

Anyway, add this to your ~/.screenrc:

zombie kr
verbose on

and then screen will leave your zombie session open. You can then hit r to resurrect your session although in this case it will just run your command all over again which you probably don't want. Probably what you want to do is then hit ctrl-A <esc> to enter the screen scrollback mode and browse back in your previous output.

share|improve this answer
    
Yes, I could. I was just in the situation, where I already had started screen in the non-optimal way... anyway doing as you suggest may result in the shell (say bash) doing an auto-logout so it will just postpone the problem. –  Jarl Mar 1 '11 at 22:47
add comment

Your Answer

 
discard

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.