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?

  • 2
    Please post your script that calls screen. – Gene Oct 14 '14 at 8: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 8: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 9:22
  • @kasperd We are using all defaults provided by CentOS. We didn't change anything – Jeroen De Meerleer Oct 14 '14 at 9:24
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.

  • 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 8: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 9: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 9: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 6:37
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.

  • 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 8: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 9: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 serverfault.com/questions/636817/… – Jenny D Oct 14 '14 at 9: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 9:35

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.