I'm trying to get the output of a GNU Screen to a log file in real time. I've tried using tee, but that appears to not work with screen. The log function for screen will not work for this as it is not in real time, I'm pretty sure. Any ideas?


2 Answers 2


It depends what you mean by realtime. The log function for screen can dump the session every second. From the manual:

Command: logfile filename

Command: logfile flush secs

Defines the name the log files will get. The default is ‘screenlog.%n’. The second form changes the number of seconds screen will wait before flushing the logfile buffer to the file-system. The default value is 10 seconds.

  • 1
    By real time I mean whenever an output occurs Feb 8, 2014 at 15:40
  • 2
    @VoidWhisperer, well then, use logfile flush 0 Feb 8, 2014 at 16:54
  • 3
    What exactly would that do, constantly flush the file? That seems like it would put alot of unnecessary load Feb 8, 2014 at 17:04
  • 2
    FYI calling logfile filename and logfile flush secs changes the behavior of gnu screen logging (i.e. where to save the logfile and what rate to flush to file)... but does not open the logfile and start logging. you still need to do log command or C-a H. Then you will see a message from gnu screen stating the log file has been opened at so and so filename. Mar 7, 2016 at 20:02

If you press C-a H screen will start recording everything to a file called screenlog.X (where X is a number starting at 0).

  • Where is this file stored? Is this equivalent to start screen with -L? Mar 17, 2015 at 13:13
  • 2
    OK, I found out the answer. The file is located on the directory which the screen command was issued, and yes, it is equivalent to -L Mar 17, 2015 at 13:16
  • But isn't it only written to every 10 seconds (by default)? Dec 30, 2019 at 2:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.