0

I am running a background process on Mac and have a problem with log update. If I run

someprog > mylog &

then mylog is updated not immediately, but with some intervals - I guess it's due to buffering. If I kill the program before output is written to the log, then I loose the data. There was no such problem with the same program on Linux machines, so I hope I can make it run-time-updated on Mac as well. Any idea how?

someprog is a F77 program, which was not written by me.

2 Answers 2

1

One solution is to use the expect command unbuffer, which redirects output to a pseudoterminal. In UNIX-like operating systems terminal output is line-buffered while non-terminal output is buffered (4k on my OpenBSD workstation)

$ sysctl hw.pagesize       
hw.pagesize=4096

See also

0

Is the program myprog an application you have written yourself?

If so, you can force it to flush the output buffers at each write statement. Output is buffered in most cases by default to avoid excessive I/O but in this case it looks like you want to get everything right away.

3
  • Unfortunately, it is not my program, so I hope there is a way to flush it somehow from the system side.
    – Andy
    Sep 21, 2010 at 13:36
  • Do you have access to the source? and are building it yourself?
    – dtlussier
    Sep 24, 2010 at 20:29
  • I don't feel like changing the source. It works fine on Linux machine, so it should work on Macs as well. It must be a system setting.
    – Andy
    Oct 1, 2010 at 14:18

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .