指定每日日志轮换时间

Kha*_*led 38 server 10.04 logrotate

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

每天有一个日志文件很不错。

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

小智 40

/etc/crontab说的行中编辑

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

以便25 6阅读0 0。这将使所有脚本在/etc/cron.daily午夜运行。

如果您只想让 logrotate 在午夜运行,请移至/etc/cron.daily/logrotate其他目录,并添加以下行

0 0    * * *   root    /new/path/to/logrotate/script
Run Code Online (Sandbox Code Playgroud)

/etc/crontab.