Sign up ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I have an application creating logfiles in a structure like this:

  production_environment-2012-07-02__23_51_50-1341265910-some name.log
  production_environment-2012-07-02__23_51_52-1341265912-some other name.log
   production_environment-2012-07-03__04_26_47-1341282407-third name.log
   production_environment-2012-07-03__04_26_47-1341282407-more names.log

I am looking for a good way to rotate those logdirectories.

If possible I would like to compress the files in each directory (no problem with logrotate) and rotate the dated directories (not possible with logrotate?).

I am hesitant to script something like this myself since I am sure that there are some good tools out there to do this kind of job.

Any ideas how to approach this?

share|improve this question
What do you mean by "rotate the dated directories"? Remove any older than one month (or whatever period you specify)? – cjc Jul 6 '12 at 12:59
Yes this is what I mean with rotating the directories. I want to keep the last N directories (not every day mail logs are created). – FadenB Jul 8 '12 at 14:33
Hmm. In that case, it's probably better to set up your own daily cron job to sweep the directories. I can't think of anything off-hand that will do what you want, and, when I've had similar situations, I've tended to write my own script. – cjc Jul 9 '12 at 0:00

Your Answer


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

Browse other questions tagged or ask your own question.