指定每日日志轮换的时间

我注意到/etc/logrotate.d/下列出的每日日志轮换是在早上6:40左右执行的。 从日志文件的开头和结尾可以清楚地看到这一点。 我可以自定义此时间并将其设置为午夜吗?

每天有一个日志文件很好。

如果这很重要,我正在使用ubuntu服务器10.04。

编辑说明的行

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

/etc/crontab ,使25 6读取0 0 。 这样可以使/etc/cron.daily中的所有脚本都在午夜运行。

如果您只想在午夜运行logrotate,请将/etc/cron.daily/logrotate移动到其他目录,然后添加该行

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

/etc/crontab的末尾。

如果在服务器上安装了Webmin / Virtualmin,则可以更轻松地更改logrotate执行时间:

只需转到Webmin -> Scheduled Cron Jobs并选择每日cron。 根据需要进行修改并保存。