Robert Mark Bram
Robert Mark Bram

Reputation: 9795

logrotate daily not kicking in

As far as I can see, I have set up logrotate correctly, but the logs are simply never rotating.

I have set up logrotate with the following config:

/path/to/logs/my_script.log {
  daily
  dateext
  copytruncate
  rotate 400
  missingok
  compress
}

When I look at permissions of the log directory I see:

Thu Jun  9 2016, 09:56:56 AM /path/to/logs
root@my_host $ ls -lath
total 2.0M
-rw-r--r--.  1 qaf qaf 472K Jun  9 09:57 my_script.log
-rw-r--r--.  1 qaf qaf   98 Jun  8 15:50 my_script.logrotate.status
drwxr-xr-x.  3 qaf qaf 108K Jun  8 15:50 .
drwxr-xr-x. 13 qaf qaf 4.0K May 28 22:42 ..

When I use logrotate -ds, it tells me that the logs need rotating.:

Thu Jun  9 2016, 09:57:00 AM /path/to/logs
root@my_host $ logrotate -ds /path/to/logs/my_script.logrotate.status /etc/logrotate.d/my_script.logrotate.conf
reading config file /etc/logrotate.d/my_script.logrotate.conf
reading config info for /path/to/logs/my_script.log
Handling 1 logs
rotating pattern: /path/to/logs/my_script.log  after 1 days (400 rotations)
empty log files are rotated, old logs are removed
considering log /path/to/logs/my_script.log
  log needs rotating
rotating log /path/to/logs/my_script.log, log->rotateCount is 400
dateext suffix '-20160609'
glob pattern '-[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]'
copying /path/to/logs/my_script.log to /path/to/logs/my_script.log-20160609
truncating /path/to/logs/my_script.log
compressing log with: /bin/gzip

Here is my /var/lib/logrotate.status

Thu Jun  9 2016, 10:00:13 AM /path/to/logs
root@my_host $ cat /var/lib/logrotate.status
logrotate state -- version 2
"/var/log/yum.log" 2016-1-1
"/var/log/sssd/*.log" 2015-1-29
"/var/log/dracut.log" 2016-1-1
"/var/log/wtmp" 2015-1-29
"/var/log/spooler" 2016-6-5
"/var/log/btmp" 2016-6-1
"/var/log/maillog" 2016-6-5
"/path/to/logs/my_script.log" 2016-6-9
"/var/log/cups/*_log" 2015-1-29
"/var/log/wpa_supplicant.log" 2015-1-29
"/var/log/secure" 2016-6-5
"/var/log/numad.log" 2015-1-29
"/var/log/ppp/connect-errors" 2015-1-29
"/var/log/messages" 2016-6-5
"/var/account/pacct" 2015-1-29
"/var/log/cron" 2016-6-5

Upvotes: 0

Views: 318

Answers (1)

Nived Karimpunkara
Nived Karimpunkara

Reputation: 367

Try restarting cron demon and rsyslog

  1. service crond restart

  2. service rsyslog restart

Upvotes: 1

Related Questions