Not sure if this is possible at all.

And what about empty lines?


Testing the config with

logrotate -d /etc/logrotate.d/apache2


error: /etc/logrotate.d/apache2:1 lines must begin with a keyword or a filename (possibly in double quotes)

for every empty line in the config file.

Original question about comment syntax is answered, though.

Update 2: This config now seems to work for me (note that it restarts apache after rotation):

/var/log/apache2/*.log {
    # https://stackoverflow.com/questions/26482773/apache-and-logrotate-configuration
    su root adm
    rotate 14
    create 640 root adm
    # https://stackoverflow.com/questions/25845752/logrotate-suffix-dateext-rotate
    dateformat -%Y-%m-%d.log
        systemctl restart apache2 || true
man logrotate

Note that comments may appear anywhere in the config file as long as the first non-whitespace character on the line is a #.

| improve this answer | |
  • Hm ok thanks, I guess I was confused by the error I was getting, which I thought was because of my hash - error: /etc/logrotate.d/apache2:1 lines must begin with a keyword or a filename (possibly in double quotes). Will accept as soon as I get the config working. – Reto Höhener Aug 8 '18 at 19:30
  • 1
    try sudo logrotate -v confName it might help you diagnose the problem... – Ravexina Aug 8 '18 at 19:34
  • I am running logrotate -d /etc/logrotate.d/apache2 as root to check my config, which got me the error. – Reto Höhener Aug 8 '18 at 19:43
  • My logrotate file would NOT tolerate any comments. But I'm on RedHat EL7. – Marcus Mar 19 '19 at 12:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.