Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I currently have a log file which has no limit and I was hoping to be able to set up a cron job that would start writing to a new file so it doesn't get too big. Would that be possible? So it would keep the old one with a date and start a new one, with a 10MB size limit.

share|improve this question

2 Answers 2

This problem is common enough that there's a whole program to do that, logrotate, which can also zip the old files, only keep the last X, and pretty much most things you could reasonably want to do with old logfiles.

share|improve this answer
    
Oh thanks for that will take a look :) –  scott marriott May 29 '13 at 20:04
    
I was actually just thinking of writing a script to rename the file and set a cron job to run it once a month –  scott marriott May 29 '13 at 20:14

You are looking for logrotate. Hard not to find that with a short look at your favorite search engine.

share|improve this answer
3  
It may be hard if you call it “casting up cron jobs” (I have no idea what that's supposed to mean). –  Gilles May 30 '13 at 0:08

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.