Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I noticed that daily log rotations which are listed under /etc/logrotate.d/ are executed in the morning around 6:40 am. This is clear from the beginning and ending of the log files. Can I customize this time and set it to midnight for example?

It is nice to have one log file per day.

I am using ubuntu server 10.04 if that matters.

share|improve this question

1 Answer 1

up vote 11 down vote accepted

Edit the line that says

25 6    * * *   root    test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily )

in /etc/crontab so that the 25 6 reads 0 0. This will make it so that all scripts in /etc/cron.daily runs at midnight.

If you only want to make logrotate run at midnight, move /etc/cron.daily/logrotate to some other directory, and add the line

0 0    * * *   root    /new/path/to/logrotate/script

at the end of /etc/crontab.

share|improve this answer
1  
You might also want to make corresponding changes to the weekly and monthly lines in the same file. I'm guessing that keeping them in the same relative order (daily, weekly, monthly) and spacing is a good idea. –  nealmcb Feb 13 '11 at 7:21

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.