12

我的 iptables 有以下 logrorate 配置:

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

当我尝试检查文件语法时,出现以下错误:

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)

我的配置文件有什么问题?

4

2 回答 2

14

您应该能够Unix在编辑器中以某种格式保存文件。

如果你想从终端解决这个问题,这里有很多建议:

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

例如,您可以试试这个:

dos2unix -b /etc/logrotate.d/iptables

where-b代表备份

或者自己创建一个备份:

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

然后尝试:

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

上面的链接中还有很多其他建议。

于 2014-03-10T17:05:53.153 回答
6

用 LF 替换 CR 线终结器

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

于 2014-03-10T16:27:15.110 回答