2

I have below configuration for access logs

cat /etc/logrotate.d/logrotate_nginx.conf
/nginx/access/logs/*.log {
  rotate 2
  size 1k
  missingok
  compress
  notifempty
  copytruncate
}

There is no time interval configuration.

This should mean it has rotate logs at '/nginx/access/logs/' after they reach 1 KiloByte right?

But this is the log rotation now

/ # ls -l /nginx/access/logs/
total 8
-rw-r--r--    1 root     root          1264 Jun 24 11:17 nginx-access.log
-rw-r--r--    1 root     root          1292 Jun 24 11:17 nginx-access_withbody.log
-rw-r--r--    1 root     root             0 Jun 24 11:16 nginx-error.log

This is logrotate.status

/ # cat /var/lib/logrotate.status
logrotate state -- version 2
"/var/log/acpid.log" 2019-6-24-11:0:0
"/mnt/mesos/sandbox/logs/nginx-error.log" 2019-6-24-11:0:0
"/mnt/mesos/sandbox/logs/nginx-access.log" 2019-6-24-11:0:0
"/mnt/mesos/sandbox/logs/nginx-access_withbody.log" 2019-6-24-11:0:0

I want to know why it is not rotating. If the issue is with conf. And as per document

Size size

This option is mutually
exclusive with the time interval options, and it causes log
files to be rotated without regard for the last rotation time, if specified after the time criteria
  • 1
    How often is logrotate started? Did it run again after the files reached 1k in size? – Kusalananda Jun 24 at 11:14
  • I placed logrotate in /etc/periodic/daily/. But does not seem to work. Is this right? Also I tried by placing /etc/periodic/15min/. Is whatever I am doing and expecting correct? – Sachin DG Jun 25 at 12:31
1

From the logrotate.status file that you include, it looks like the logs were last rotated at 11:00, and from the directory listing one can see that the files were updated after that.

This possibly means that the logrotate jobs runs hourly. Your logs should be rotated when the log rotation job runs again, or when you run it manually.

0

In Alpine Linux, cron is not started by default. Hence jobs in any folder would not be executed. Solution was to to start cron with crond

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.