Specify the time of daily log rotate
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.
Solution 1:
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
.
Solution 2:
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.