如果我有每周一次的日志轮换配置并且每隔一天重新启动我的设备会怎样?

What happens if I have a weekly log rotate configuration and I reboot my device every other day?

我有一个每周日志轮换配置,但我的设备开机时间从未超过一周。它是否执行过日志轮换?或者设备是否需要通电一周以上才能触发旋转?

/path/to/my/log.log
{
    rotate 4
    weekly
    maxsize 150M
    missingok
    notifempty
    compress
    delaycompress
    sharedscripts
    postrotate
        invoke-rc.d rsyslog rotate > /dev/null
    endscript
}

Red Hat Linux 和系列,以及 Debian GNU/Linux 和系列通常安装了 anacron。

每次启动计算机时都会执行 Anacron,它会检查 cron 的最后日期 运行ning。如果最后一个日期距离今天超过 7 天,则 /etc/cron.weekly 中的脚本将为 运行.

如果 logrotate 在 /etc/cron.weekly 内,那么它将由 cron

运行