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

标签 ubuntu logrotate

我的 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)

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

最佳答案

您应该能够在编辑器中以 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-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

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

关于ubuntu - logrotate : error: lines must begin with a keyword or a filename (possibly in double quotes),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22267563/

相关文章:

linux - 从终端更改 Ubuntu 12.04 中的系统代理设置

docker - ubuntu 18.04 服务器 ufw 即使在配置 DOCKER_OPTS ="iptables=false"后也没有阻塞

c - "/dev/ttyUSB0"在 Windows 中等效

cron - uwsgi logrotate 不工作

tomcat - 使用 logrotate 轮换 apache 日志

linux - logrotate 在 postrotate 脚本之后压缩文件

linux - $0 在 Redhat 和 Ubuntu 上给出不同的结果?

wordpress - 在 LAMP 上授予 Wordpress 权限 - Ubuntu

ubuntu - logrotate: 打开 <log>.gz 时出错

tail - "tail -f"和 logrotate 如何工作?