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

Issues related to applications and software problems
Post Reply
Davidl2901
Posts: 2
Joined: 2017/01/04 15:28:49

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

Post by Davidl2901 » 2019/02/15 17:22:19

Hello,

I have a centos 7 rsyslog server that I am using for my network gear (SRX). getting the logs is working great but I am trying to setup to rotate the logs. the log is located in /var/log/<filename.log>. I have log rotate setup as,
/var/log/<filename.log> {
missingok
weekly
rotate 5
maxsize 10m
compress
}

when I do a test run i get long list of error saying lines must begin with a keyword or file.

any help would be appreciated.

lightman47
Posts: 1521
Joined: 2014/05/21 20:16:00
Location: Central New York, USA

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

Post by lightman47 » 2019/02/15 21:18:56

Exactly what file are you editing in the quest for your desired result (a given log to 'rotate')? I remember having issues myself a year or two ago. When I installed CentOS, logrotate was all setup by default.

What exactly is your "test run"?

hunter86_bg
Posts: 2019
Joined: 2015/02/17 15:14:33
Location: Bulgaria
Contact:

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

Post by hunter86_bg » 2019/02/16 17:17:58

Run logrotate command in debug mode and only for your specific logrotate file and provide full output here.

Something like:

Code: Select all

logrotate -df /etc/logrotate.d/my.conf

Davidl2901
Posts: 2
Joined: 2017/01/04 15:28:49

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

Post by Davidl2901 » 2019/02/19 14:54:15

I am editing the /etc/logrotate.conf file. I added my log file which is /var/log/ATLFW01_*.log this is the file all my logs are going to. when I try to do a test run of logrotate -d /var/log/ATLFW01_*.log i get a bunch of lines that say the error above.

User avatar
TrevorH
Site Admin
Posts: 33202
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

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

Post by TrevorH » 2019/02/19 16:05:17

Then you almost certainly have a syntax error in your additions - most likely you forgot to close a {} pair or something like that.

It's not intended that you edit that file anyway. Logrotate is set up so that each service and/or file that you want it to process should be in a separate file in /etc/logrotate.d as those are all included from logrotate.conf using "include /etc/logrotate.d".

Also, I just noticed that you invoked logrotate and pointed to the logfile you want to process when you should be pointing it to the _config_ file that you want to process. It's trying to read your logfile as a config file and not finding any valid syntax in it (unsurprisingly).
The future appears to be RHEL or Debian. I think I'm going Debian.
Info for USB installs on http://wiki.centos.org/HowTos/InstallFromUSBkey
CentOS 5 and 6 are deadest, do not use them.
Use the FAQ Luke

liverpoolfcfan
Posts: 2
Joined: 2015/11/17 09:23:49

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

Post by liverpoolfcfan » 2019/08/09 16:52:42

I ran into this today. You most likely created the file on a windows machine. You need to make sure the Unix EOL format is used. This error gets thrown up when a <CR> character is encountered.

Post Reply