Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!usc!brutus.cs.uiuc.edu!jarthur!bridge2!mips!smsc.sony.com!dce From: dce@smsc.sony.com (David Elliott) Newsgroups: comp.unix.questions Subject: Re: How to flush output to disk? Keywords: flush buffer disk Message-ID: <1989Dec6.211440.20629@smsc.sony.com> Date: 6 Dec 89 21:14:40 GMT References: <606@caldwr.UUCP> <1025@friar-taac.UUCP> Reply-To: dce@Sony.COM (David Elliott) Distribution: na Organization: Sony Microsystems Corp. Lines: 28 In article <1025@friar-taac.UUCP> matthew@friar-taac.UUCP (Matthew Stier - Sun Visualization Products) writes: >In article <606@caldwr.UUCP> rfinch@caldwr.UUCP (Ralph Finch) writes: >> >>Is there any way to force the output to be flushed more often, say every 15-30 minutes? > >The following, untested, script should do it. (I know using 'sync' is a little heavy >handed, but it gets the job done.) Are we talking about the same thing? Maybe SunOS changed this, but on most BSD systems, the disk buffers are written every 30 seconds via the /etc/update command. Even if they weren't, when you open a file that someone has written to, you get pages from the buffer cache first, so you should get the data. The problem here is (probably) that Ralph's program is using stdio to log its output, and since the data is going to a file, it gets buffered inside the program. In other words, the data hasn't even gotten written yet. The easiest way to fix this is to modify the program to either call fflush() at certain intervals to force the buffers to be written, or call setlinebuf() (or the equivalent) to force line-buffered output. -- David Elliott dce@smsc.sony.com | ...!{uunet,mips}!sonyusa!dce (408)944-4073 "It's bigger than a breadbox, and smaller than the planet Jupiter."