I read the man logrotate, but it's still unclear to me. My questions are mainly related to the NGINX webserver logs.

This is my current logrotate.conf:

# rotate log files weekly

# keep 4 weeks worth of backlogs
rotate 4

# create new (empty) log files after rotating old ones

# use date as a suffix of the rotated file

# uncomment this if you want your log files compressed

# RPM packages drop log rotation information into this directory
include /etc/logrotate.d

# no packages own wtmp and btmp -- we'll rotate them here
/var/log/wtmp {
    create 0664 root utmp
        minsize 1M
    rotate 1

/var/log/btmp {
    create 0600 root utmp
    rotate 1

and in /etc/logrotate.d I have among the others also: nginx:

/var/log/nginx/*log {
    create 0644 nginx nginx
    rotate 10
        /bin/kill -USR1 `cat /run/nginx.pid 2>/dev/null` 2>/dev/null || true

And these are some of the .gz I can see:

access.log-20150509.gz (created after ~10 days)
access.log-20150524.gz (created after ~15 days)
access.log-20150528.gz (created after ~4 days)
  1. Why the .gz logs are created so often and at so "random" timeframes?
  2. What should I change in order to have new .gz created every 6 months and/or after a .log file will be bigger than 100MB?
  3. With rotate 10 does it mean that if I have already 10 .gz files, then when it compresses the 11th, it will automatically delete the oldest .gz file? If yes, how can I avoid deleting logfiles? I must keep them all, even if very old.
  4. What is the difference between daily and rotate 10?
  5. Is the create permission for those files ok?
  6. After I change something on the logrotate.conf, should I restart some service, or the changes should be applied immediately?

I think logrotate manual is clear about most of your points. Here are my answers:

  1. Using daily causes log rotation to happen every day. So, you need to check why it is not happening on daily basis. For example, this can be caused by the other option notifempty if the log file was empty for few days.
  2. I can't find an option to do it every 6 months, but you have monthly and yearly. For the size confitions, you can use size 100M.
  3. Yes. To keep them all, you can choose a very large value.
  4. daily specifies how often to rotate while rotate specifies number of log files kept.
  5. If the log does not contain sensitive information (others can read), it should be fine.
  6. No, you don't need to restart anything.

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.