I have a problem with screen. Basically I want it to make one log per screen, for example screen #1 will be screenlog.1 & screen #2 will be screenlog.2 - you get the memo.

Anyhow, what happens is that when I launch screen using:

screen -SL screen1

(The -L parameter is because I need to force it to make logs) it only logs the first screen, not the rest 2-5 screens. I've tried using the .screenrc file with the logfile parameter, it works - but just changes the name of screenlog.0, which isn't really what I want.

Any idea how I would go about this?

Additonal information: CentOS 6.3 (64bit). Screen version 4.00.03 (FAU) 23-Oct-06.

  • Or use tmux which makes all of these automation projects so much less painful than screen ever did. – chicks Jul 21 '17 at 12:15

Here is how you can log the output of multiple screen sessions in separate log files:

  1. Start a screen session using screen -S <preferred-name-of-session>
  2. Attach the screen using & then set the logfile of the screen using the command: Ctrl + a :logfile <name-of-log-file>
  3. Start the screen logging by running Ctrl + a H
  4. Execute the required program & then detach the screen

This might look like a lot of work everytime but once you start using it, it becomes very handy!


You may be experiencing buffering of the log output.

I locally tested both with and without screen name and received the expected screenlog.0 and .1 and .2 etc. Each log corresponded to the contents of each window. There is a buffer before it gets written to disk

Reference flush secs: http://www.gnu.org/software/screen/manual/screen.html#Logging


In addition to what splaer said (which is probably what's going on here), you might want to use script to record your sessions if screen is giving you trouble.

The convenience of screen -L is nice to have, but if it's giving you trouble script is a handy workaround (and if you ever find yourself on a machine without screen -- they do still exist sadly -- it's likely script is still going to be there).

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.