vikram keshari
vikram keshari

Reputation: 73

automatic log rotation is not executing

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?

Upvotes: 1

Views: 1691

Answers (1)

Hamza Bilal
Hamza Bilal

Reputation: 11

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

Upvotes: 1

Related Questions