I'm looking for a cronolog-like tool that will keep only last n lines or last x minutes of logs piped to it and discard everything else
Is there such a beast?
UPDATE:
I know about logrotate and it renames and zips old logfiles, which is not what I want.
I want to discard old log lines and keep only recent lines.
Like i.e. doing this every so often: tail -10000 logfile > logfile.new mv logfile.new logfile except that with this technique you will most certainly lose log lines and you have to restart or otherwise signal the logging application to reopen the logfile.
Best Answer
Logrotate can be made to only keep one copy of a logfile... If you RTFM you'll find the following bit regarding configuration settings:
You can couple rotate with size, again from the logrotate(8) man page, to keep the file size small. While not by number of lines but by k, M, G size.