GNU Screen: How to enable or disable logging while screen is already attached?

27,772

To enable logging on the current window of a screen session, press Ctrl+AH (uppercase H, Shift+H if you prefer).

That actually toggles the logging state (so if the windows was being logged beforehand, it is now no longer logged).

That's the log command in screen, so you can also do Ctrl+A: and enter log (or log on to turn it on instead of toggling the state), or run screen -X log on within the shell running in the current window.

To enable logging on all windows, use the at command to apply that to all windows:

screen -X at '#' log on

Or press, Ctrl+A: and enter at \# log on.

For more details, see:

info -f screen --index-search=at
info -f screen --index-search=log
Share:
27,772

Related videos on Youtube

Andy Forceno
Author by

Andy Forceno

10+ years personal Linux system administration and Bash scripting experience. I'm currently teaching myself Python and some web development (flask/jinja2, css/html, javascript). At one time I was a PhD. student in Ecological Psychology, but that didn't work out. In my spare time, I'm a programmer, writer, musician, science & tech geek, and friend to felines everywhere.

Updated on September 18, 2022

Comments

  • Andy Forceno
    Andy Forceno almost 2 years

    Suppose I have an attached screen, but I forgot to execute screen -L initially. Is it possible to enable and disable the logging of the currently attached screen without re-executing screen?

    I know that it's possible to take what is essentially a screenshot of a currently attached screen by pressing Ctrl+a h (that key combo followed by h), but I want to enable persistent logging of the attached screen. Is it possible?

  • Yzmir Ramirez
    Yzmir Ramirez almost 7 years
    All I did was Ctrl+ a + : and then typed log on at the prompt. Did not need to use at \#. Anyone else confirm?
  • Stéphane Chazelas
    Stéphane Chazelas almost 7 years
    @YzmirRamirez, log on is just the equivalent of ^A H, it only logs the current window. You need at # log on to do that for every window.
  • Yzmir Ramirez
    Yzmir Ramirez almost 7 years
    Ctrl + a + h creates a hardcopy.0 file of the current screen.
  • Stéphane Chazelas
    Stéphane Chazelas almost 7 years
    @YzmirRamirez, yes and Ctrl + a H (capital h, shift + h) toggles logging for the current Window as this answer is saying.