I have a program that generates large logs on the standard output. Actually I don't care about the log, but I do want to know the last 1000 lines or so if the program finishes or crashes.
I want something in-between "tail -f" and "> log".. that is to say, I want to monitor the output and put it in a log file, but continuously only save the last 1000 lines to a file. If I do "tail -f >log" this saves everything continuously and the log file gets too big. If I do "tail -f", I can monitor the tail of the output.
I want something that theoretically does,
$ program >log &
$ while true; do sleep 1s; tail -n1000 log > saved_log; done
but without producing log
in-between, since it grows too big. Does such a tool exist?
Standard Unix toolkit preferred, but I'm open to suggestions.