35

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.

36

Edit in /etc/crontab the line that says

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

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.

  • 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
1

If you have Webmin/Virtualmin installed on your server you can change your logrotate execution time easier:

Just go to Webmin -> Scheduled Cron Jobs and Select daily cron. Modify it as you want and save it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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