Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

logrorate: error: lines must begin with a keyword or a filename (possibly in double quotes)

I have the following logrorate config 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 checking for file syntax I 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's wrong in my config file?

like image 206
Erik Avatar asked Mar 08 '14 09:03

Erik


2 Answers

You should be able to save your file in a Unix format in your editor.

If you want to solve this from the terminal, there are lot's of suggestions here:

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/

You can for example try this one:

dos2unix -b /etc/logrotate.d/iptables

where -b stands for backup.

Or create a backup yourself:

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

and then try:

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

There are lot's of other suggestions in the links above.

like image 55
birgire Avatar answered Nov 11 '22 16:11

birgire


Replace CR line terminators by LF

http://www.cyberciti.biz/faq/howto-unix-linux-convert-dos-newlines-cr-lf-unix-text-format/

like image 30
Céline Aussourd Avatar answered Nov 11 '22 16:11

Céline Aussourd