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?


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 – VoidWhisperer Feb 8 '14 at 15:40
  • 2
    @VoidWhisperer, well then, use logfile flush 0 – Stéphane Chazelas Feb 8 '14 at 16:54
  • 3
    What exactly would that do, constantly flush the file? That seems like it would put alot of unnecessary load – VoidWhisperer Feb 8 '14 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. – Trevor Boyd Smith Mar 7 '16 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? – Bruno Finger Mar 17 '15 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 – Bruno Finger Mar 17 '15 at 13:16
  • But isn't it only written to every 10 seconds (by default)? – Peter Mortensen Dec 30 '19 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.