如何在debian系统上自定义时间旋转特定日志?

问题描述 投票:0回答:1

在我的debian系统上,我有许多日志通过位于/etc/logrotated.d/目录中的配置文件每天轮换。

我需要改变特定日志的旋转时间,比如backup.log;旋转配置位于/etc/logrotated.d/backup.conf。我想让backup.log在凌晨1点旋转,而不改变全球轮换时间。

我该怎么做?

logrotate
1个回答
0
投票

这很简单:

  1. /etc/logrotated.d/backup.conf移到/etc/logrotate_backup.conf
  2. 将以下行添加到/etc/crontab 0 1 * * * root /usr/sbin/logrotate /etc/logrotate_backup.conf backup.log的轮换将在凌晨1点启动。 或者,您可以将该行放在/etc/cron.d/中的自定义文件中。例如/etc/cron.d/logrotate_backup
© www.soinside.com 2019 - 2024. All rights reserved.