voxpupuli/puppet-logrotate

hourly cron doesn't work

Closed this issue · 3 comments

Affected Puppet, Ruby, OS and module versions/distributions

  • Puppet: 5.5
  • Ruby: 2.3.1
  • Distribution: ubuntu
  • Module version: 3.4

How to reproduce (e.g Puppet code you use)

Create config:

  logrotate::rule {
    'test_file':
      path         => "/tmp/test_file.log",
      rotate_every => hour,
      rotate       => 24,
      create       => false,
    ;
  }

What are you seeing

File /tmp/test_file.log not rotated.
Logrotate even does not take in account config file /etc/logrotate.d/hourly/test_file:

What behaviour did you expect instead

Logrotate see file "/etc/logrotate.d/hourly/test_file" and parse it.

Output log

Here output of logrotate:

logrotate -dvf /etc/logrotate.conf
reading config file /etc/logrotate.conf
including /etc/logrotate.d
...
Ignoring hourly because it's not a regular file.
...

Any additional information you'd like to impart

It happens because "include" directive include only regular files, not directories.
quote from man logrotate:

The only files which are ignored are files which are not regular files (such as directories and named pipes) ...

So, directory /etc/logrotate.d/hourly and files in it just not parsed by logrotate.
You need place hourly configs in directory /etc/logrotate.d.
OR you need include dir "/etc/logrotate.d/hourly" in logrotate.conf (add include /etc/logrotate.d/hourly in templates/etc/logrotate.conf.erb)

The module should have created an hourly cronjob to run the hourly log rotates.
Do you not have a /etc/cron.hourly/logrotate file?

Yes, i have this file. Problem on other side. Sorry, my bad.

@lexore No worries. Glad I could help.