0

I'm running some C++ code that prints out 1000s+ lines of code and has runtimes exceeding 10 minutes. If I send the output directly to the command line, the output updates throughout program execution. However, when I capture the output (./program > out.log), the file only records a fixed number of lines, losing the remaining output if I kill the program halfway through. Is there a way to have the file also update in real time?

C. Kang
  • 108
  • 9
  • This probably has nothing to do with bash. You'll probably want to flush the output buffer frequently. Chances are good that your program is still running and you just don't know it. Use output to STDERR to provide status updates that don't interfere with your regular output. – PaulProgrammer Aug 10 '20 at 18:07
  • 1st method seems unefficient ... if you need logs manage them from your own source code. 2cd you seem confused about `>` and `>>` and `2>&1` redirections .... 3rd you should use a dedicated fifo to write your files 4th if it is logs use /var/log or application directory :) – francois P Aug 10 '20 at 18:16
  • Thanks all for the comments! The suggested question helps a lot; PaulProgrammer the suggestion to use stderr helps a lot, especially for status updates, and francois P, I should probably be outputting directly to file :D – C. Kang Aug 10 '20 at 18:36

0 Answers0