I have a process that outputs a line for every progress update (sidenote: it does clear/replace the line, no pure newline break).
I want to save the latest line of that process to an output file or truncate the output file to keep the size manageable.
At the moment I have
genrtr > genrtr.log
and with a cron I tried to use
> genrtr.log but it doesn't work. Also
rm genrtr.log doesn't help because then the process stops updating the file.
I understand why those don't work, but wonder how to restructure it so it fits my needs.
genrtr | sed -ne '$w genrtr.log' but then it waits for the process to end before writing to the file.
Clarifications: The process produces output every 1 second and unless the server crashes the process will keep running for ever.