0

I have configured log rotation on my Ubuntu server named custom in the directory /etc/logrotation.d/custom the entries are as follows

/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
}

But when I run the command logrotate -f /etc/logrotate.d/custom it gives the following error.

logrotate -f custom 
error: custom:3 unexpected text

It gives error in the line mailfirst tarun@example.com. Why? Please Help.

Tarun
  • 127
  • 1
  • 7

1 Answers1

1

It should be:

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
}
Danila Ladner
  • 5,331
  • 22
  • 31