Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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 info, 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?

share|improve this question
up vote 2 down vote accepted

Try this:

screen -r session1 -X colon "logfile flush 1^M"

logfile flush 1 isn't actually a screen command, but colon 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.

share|improve this answer
Thank you very much. Also, I was having problems with Ctrl-V Ctrl-M: it did print ^M in the command line, but then simply printed ^M in the screen window. Might have been the quotes. I ended up using this: screen ... -X stuff "$(printf '%b' 'this into input\015')". – Gipsy King Oct 19 '10 at 12:49

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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