10

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)

2 Answers 2

9

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.

4
  • +1 for clarification that you could do this on the fly without editing your .screenrc. Feb 20, 2011 at 8:53
  • 1
    zombie kr onerror - this is the syntax to leave zombie screen only when exit code is > 0. I wasn't able to do it. Screen stays open even if exit is 0. When I resurrect (restart) the process it exits cleanly if 0. Someone soled this? Jun 8, 2015 at 13:36
  • @AntonValqk - you should open a new question; it will be a lot more visible and you'll get better answers.
    – Jander
    Jun 8, 2015 at 20:30
  • Just to report. Debian version of screen 4.3.1-1 works fine. If I start screen -d -m ./exit.sh 0 && screen -d -m ./exit.sh 1 then I see only 1 screen (the second one) as expected. Jul 25, 2015 at 7:56
7

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.

1
  • 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, 2011 at 22:47

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .