在我的debian系统上,我有许多日志通过位于/etc/logrotated.d/
目录中的配置文件每天轮换。
我需要改变特定日志的旋转时间,比如backup.log
;旋转配置位于/etc/logrotated.d/backup.conf
。我想让backup.log
在凌晨1点旋转,而不改变全球轮换时间。
我该怎么做?
这很简单:
/etc/logrotated.d/backup.conf
移到/etc/logrotate_backup.conf
/etc/crontab
0 1 * * * root /usr/sbin/logrotate /etc/logrotate_backup.conf
backup.log
的轮换将在凌晨1点启动。
或者,您可以将该行放在/etc/cron.d/
中的自定义文件中。例如/etc/cron.d/logrotate_backup
。