日志轮换无法处理 mailfirst

日志轮换无法处理 mailfirst

我已经在 Ubuntu 服务器上配置了日志轮换,custom目录中的/etc/logrotation.d/custom条目如下

/var/log/apache2/access.log {
        daily
        mailfirst [email protected]
        missingok
        rotate 52
        compress
        delaycompress
        notifempty
        create 640 root adm
        sharedscripts
        postrotate
                /etc/init.d/apache2 reload > /dev/null
        endscript
        prerotate
                if [ -d /etc/logrotate.d/httpd-prerotate ]; then \
                        run-parts /etc/logrotate.d/httpd-prerotate; \
                fi; \
        endscript
}

但是当我运行命令时,logrotate -f /etc/logrotate.d/custom它出现以下错误。

logrotate -f custom 
error: custom:3 unexpected text

这行代码出错了。为什么?请帮忙。mailfirst [email protected]

答案1

它应该是:

var/log/apache2/access.log {
        daily
        mail [email protected]
        mailfirst 
        missingok
        rotate 52
        compress
        delaycompress
        notifempty
        create 640 root adm
        sharedscripts
        postrotate
                /etc/init.d/apache2 reload > /dev/null
        endscript
        prerotate
                if [ -d /etc/logrotate.d/httpd-prerotate ]; then \
                        run-parts /etc/logrotate.d/httpd-prerotate; \
                fi; \
        endscript
}

相关内容