Logrorate: error: lines should begin with a keyword or file name (possibly in double quotes)

I have the following logrotate configuration for my iptables:

/var/log/iptables.log {
        daily
        missingok
        rotate 3
        compress
        notifempty
        delaycompress
        postrotate
        /usr/sbin/service rsynclog restart > /dev/null
        endscript
}

When I try to issue a syntax check for a file, I get the following error:

sudo logrotate -vf /etc/logrotate.d/iptables

reading config file iptables
reading config info for /var/log/iptables.log 
error: iptables:1 lines must begin with a keyword or a filename (possibly in double quotes)

What is wrong in my configuration file?

+4
source share
2 answers

You must save the file in a format Unixin your editor.

If you want to solve this problem from the terminal, there are many suggestions:

https://superuser.com/questions/52044/convert-crlfs-to-line-feeds-on-linux https://superuser.com/questions/156516/is-there-a-bash-command-to-convert-r-n-to-n http://www.cyberciti.biz/faq/howto-unix-linux-convert-dos-newlines-cr-lf-unix-text-format/

, , :

dos2unix -b /etc/logrotate.d/iptables

-b .

:

cp /etc/logrotate.d/iptables /etc/logrotate.d/iptables.bak

:

tr -d '\r' < /etc/logrotate.d/iptables > /etc/logrotate.d/iptables

.

+7

Source: https://habr.com/ru/post/1530732/


All Articles