Log output of GNU screen in real time?
Solution 1
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.
Solution 2
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).
Related videos on Youtube
VoidWhisperer
Updated on September 18, 2022Comments
-
VoidWhisperer over 1 year
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?
-
Peter Mortensen about 4 years
-
-
VoidWhisperer about 10 yearsBy real time I mean whenever an output occurs
-
Stéphane Chazelas about 10 years@VoidWhisperer, well then, use
logfile flush 0
-
VoidWhisperer about 10 yearsWhat exactly would that do, constantly flush the file? That seems like it would put alot of unnecessary load
-
Bruno Finger about 9 yearsWhere is this file stored? Is this equivalent to start
screen
with-L
? -
Bruno Finger about 9 yearsOK, 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
-
Trevor Boyd Smith about 8 yearsFYI calling
logfile filename
andlogfile 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 dolog
command orC-a H
. Then you will see a message from gnu screen stating the log file has been opened at so and so filename. -
Peter Mortensen over 4 yearsBut isn't it only written to every 10 seconds (by default)?