Save Screen (program) output to a file

There is a command line option for logging. The output is saved to screenlog.n file, where n is a number of the screen. From man pages of screen:

‘-L’ Tell screen to turn on automatic output logging for the windows.


You can also use Control-a + H to save loggings into screenlog.n file. One more Control-a + H to turn off.

C-a H: Begins/ends logging of the current window to the file "screenlog.n".


The following command works for Screen version 4.06.02:

screen -L -Logfile Log_file_name_of_your_choice command_to_be_executed

From the man page of Screen:

-Logfile file : By default logfile name is "screenlog.0".
                You can set new logfile name with the "-Logfile" option.

You can check the existing version of Screen using screen -version. You can download and install the latest Screen version from https://www.gnu.org/software/screen/.