Ubuntu-12.04

日誌輪換無法先處理郵件

  • November 12, 2013

custom在目錄/etc/logrotation.d/custom中命名的 Ubuntu 伺服器上配置了日誌輪換,條目如下

/var/log/apache2/access.log {
       daily
       mailfirst tarun@example.com
       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 tarun@example.com。為什麼?請幫忙。

它應該是:

var/log/apache2/access.log {
       daily
       mail tarun@example.com
       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
}

引用自:https://serverfault.com/questions/554418