0

For a long running script we are using screen to be able to close the ssh session without stopping the script.

Screen, however, keeps saving the output which is resulting in a very high diskio.

My question: how can I start a screen session which does not save stdout and stderr to the disk?

peterh
  • 4,953
  • 13
  • 30
  • 44
  • 2
    Please post your script that calls screen. – Gene Oct 14 '14 at 08:18
  • That shouldn't be happening when using screen in the default configuration. What does your screen configuration look like? Sounds like you either configured to keep an excessive number of lines in (virtual) memory or configured it to log all output lines to a file. – kasperd Oct 14 '14 at 08:46
  • @Gene screen is just called by itself. We open a screen session by calling `screen` and put our commands in there. We don't call it from a script. – Jeroen De Meerleer Oct 14 '14 at 09:22
  • @kasperd We are using all defaults provided by CentOS. We didn't change anything – Jeroen De Meerleer Oct 14 '14 at 09:24

2 Answers2

3

If you're uninterested in the output of the script, then it's the script invocation that you should change rather than the screen invocation.

If you start the script with e.g.

/path/to/script.sh > /dev/null 2>&1

then there will be no output for screen to keep track of.

Jenny D
  • 27,780
  • 21
  • 75
  • 114
  • 1
    If they want the ability to attach the screen session to view the output of the process this won't work for them. – Gene Oct 14 '14 at 08:21
  • We are actually interested in the output (It is giving some valuable information about the process). We just don't want it cached on the disk. – Jeroen De Meerleer Oct 14 '14 at 09:08
  • At this point I completely fail to understand what you actually want. Where do you expect the information to go, if it doesn't get written somewhere? I think in order to get a better answer you'd need to flesh your question out a little, starting with the information requested by @Gene in http://serverfault.com/questions/636817/gnu-screen-without-output-caching/636820?noredirect=1#comment766812_636817 – Jenny D Oct 14 '14 at 09:12
  • @JennyD The information should go to our ssh-client and only to our ssh-client. At this point screen seems to be caching its output. – Jeroen De Meerleer Oct 14 '14 at 09:35
2

You can adjust screen's scrollback history size by starting screen with -h parameter, for example screen -h 1000 would make the maximum scrollback buffer size to be 1000 lines. That should help you.

Janne Pikkarainen
  • 31,852
  • 4
  • 58
  • 81
  • On the install where I just tested the history was 1048 lines by default. That is unlikely to cause much swapping. To me it sounds more likely that screen was configured to log all output to a file. – kasperd Oct 14 '14 at 08:44
  • Thanks for this solution. By putting using `screen -h 0` we get back from status critical to OK. Thanks, you're a hero. – Jeroen De Meerleer Oct 14 '14 at 09:16
  • @JeroenDeMeerleer Are you running this on a system with low memory? The scrollback buffer is written to memory, not to disk, unless it's swapping. – Gene Oct 14 '14 at 09:37
  • @Gene it is running on 2GB ram. Not sure if that would the problem. Anyway, I already changed the defscrollback to 1 (was 1000) which also solves the problem. – Jeroen De Meerleer Oct 15 '14 at 06:37