Delete file by date or by size

Hi Everyone,

This forum has been a great help to me as a new newbie in Unix. Thanks to you all.

My ? now is I have a log file that help me keep track of errors within my program. But the size of the log file keeps growing and I am wondering if there is any command that will help me to limit the size of the log file to about 10,000 lines. Or since I capture both the date and time stamp and the error message, is there anyway I can write a code to help keep up to say about 10 days of error within my log file.

Thanks for your help.

Odogbolu98

One suggestion may be that every 10 days that you swap files.
Hence you'd have two files at anyone time providing 20 days of log details (~/LogFile-A & ~/LogFile-B). Every 10 days swap between the two...for instance.

1/ Currently on LogFile-A
2/ 10 Days later swap to LogFile-B
3/ 10 Days later empty LogFile-A and swap to LogFile-A
4/ 10 Days later empty LogFile-B and swap to LogFile-B
5/ ** Keep rotating through steps 3 & 4.

Just a thought.

Try: cat LogFile-A | wc -l