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'm logging the output of a command with

command | tee file

This causes tee to actually write to the disk every second or so. I'd like to reduce the frequency of the writes, by caching the output more.

I know this can be done at the system level, for all processes, but is there a simple way to do this at the user level, just for this process?

(Having tee write to ramdisk and then having another process periodically copy the output; or modifying tee itself seem overly complicated)

share|improve this question
    
I don't understand why you accepted an answer that you said did not help you. – Lightness Races in Orbit Jan 26 at 0:31
    
@LightnessRacesinOrbit it answered it in general, and if my particular case cannot be addressed (easily), that's useful to know. If there are better answers that prove this wrong, I'll change the "accept" vote. – MaxB Jan 26 at 0:41
    
You could leave the question without an unaccepted answer to encourage more people to come along and post competing answers. You don't need to accept an answer right away. – Lightness Races in Orbit Jan 26 at 0:48
    
One write per second is not a heavy load. – Raedwald Feb 20 at 17:54
up vote 4 down vote accepted

Try

command | stdbuf -o5M cut -b-

For 5MiB output buffering. See man stdbuf for a list of options. Note this doesn't work with tee which overrides the the buffer modes.

share|improve this answer
1  
Thanks, but if this doesn't work with tee, how does this help me? – MaxB Jan 25 at 20:45
    
If you want to log the output of a command, redirect stdout to a file you want to log it to. – Matthew Ife Jan 25 at 20:47
1  
I want to get both stdout and the log file (hence tee) – MaxB Jan 25 at 20:48
    
Well, I checked and cat also doesnt work. I suppose cut will. I edited the command. tee is not designed to work this way, so pick your poison. – Matthew Ife Jan 25 at 20:52

Your Answer

 
discard

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.