I am using Screen like this:
screen -L -dm -S session1 -c "./game_server -options"
to wrap around game servers. I log their output to a file and can send them input with:
screen -r session1 -p0 -X "stuff \"this into input^M\""
The timeout between log file flushes can be specified in the configuration file (10 seconds in my case).
The problem I have is that I can't force screen to flush output to the logfile. For example, after I send a "status" command to a game server, the game server prints some information, but it takes at least 10 seconds to add that to the log file.
I have tried sending:
screen -r session1 -p0 -X "logfile flush 1"
But it doesn't react to that. I've also tried flush 0 with no luck.
I wouldn't want to always log with a timeout of 1 second; it's only really needed after receiving a command. Note that I'm paranoid about performance here because the session is running a game server after all.
How can I force screen to flush output to the logfile? Is there a way to do what I need (log output to file and send commands to input) other than with screen, maybe with a FIFO?
Try this:
logfile flush 1
isn't actually a screen command, butcolon
is. The next thing you pass is the argument to it which has to be quoted and the ^M at the end should actually be a Ctrl-M. Ctrl-V followed by Ctrl-M will generally do the trick for entering an actual Ctrl-M.I had the exact same need as you.
Logfile flush
is a valid command to send to screen - however, it doesn't need to be quoted, and you can also set it to 0 for instant flushing.Change your line to
Make sure to change it back when you are done reading from the log file though
The default is 10 seconds, but you can set it to whatever you think is appropriate.