1

This is my conf file (docker-container) for the docker log rotation :

/var/lib/docker/containers/*/*.log {
  rotate 7
  hourly
  compress
  maxsize 10M
  missingok
  create root root
  delaycompress
  copytruncate
}

and this is my command to run log rotate:

sudo logrotate -fv /etc/logrotate.d/docker-container

When I am manually running the command logs are getting rotated, but after 1 hour its not getting automatically rotated. How to enable the automatic log rotation?

Dan Lowe
  • 51,713
  • 20
  • 123
  • 112
  • 1
    Is logrotate in crontab? How often does it run? What command is in the crontab? – Dan Lowe Apr 05 '17 at 23:21
  • Yes logrotate is in crontab, and now it is rotating every hour. This is my crontab configuration : " 0 */1 * * * /usr/sbin/logrotate /etc/logrotate.d/docker-container " – vikram keshari Apr 26 '17 at 06:22

1 Answers1

1

You need to check two things here.

  1. See if your logrotate script is configured to run as daily cronjob. if logrotate script is placed in /etc/cron.daily then it doesn't matter if you specify hourly in logrotate.conf it will always execute the rotation process after a day. Move /etc/cron.daily/logrotate to /etc/cron.hourly/logrotate.
  2. See if the size of your log file is greater then 10MB, since you specified maxsize