0

I am attempting to set up logrotate. I am getting unexpected results; some log files have multiple dates and/or zero bytes in size. I would like to have a log for each day and have the date in the file name of the old log, while only keeping logs for the last 30 days.

here is my logrotate entry

/var/www/html/joomla-1.x/example.com/logs/*.log {
    missingok
    daily
    dateext
    extension .log
    rotate 30
    notifempty
    sharedscripts
    nocompress
    postrotate
        /sbin/service httpd reload > /dev/null 2>/dev/null || true
    endscript
}

the following are the log files that have bee rotated.

[root@Webserver-2 logs]# ls -la
total 72460
drwxrwxr-x. 2 apache apache    28672 Jan 13 03:08 .
drwxrwxr-x. 4 apache apache     4096 Nov 21 12:51 ..
-rw-r--r--. 1 root   root   20367769 Jan  8 03:42 access-20140108-20140110-20140112.log
-rw-r--r--. 1 root   root          0 Jan 12 03:08 access-20140108-20140110.log
-rw-r--r--. 1 root   root          0 Jan 10 03:38 access-20140108.log
-rw-r--r--. 1 root   root    9925777 Jan  9 03:21 access-20140109-20140111-20140113.log
-rw-r--r--. 1 root   root          0 Jan 13 03:08 access-20140109-20140111.log
-rw-r--r--. 1 root   root          0 Jan 11 03:26 access-20140109.log
-rw-r--r--. 1 root   root    9961813 Jan 10 03:37 access-20140110-20140112.log
-rw-r--r--. 1 root   root          0 Jan 12 03:08 access-20140110.log
-rw-r--r--. 1 root   root   10114757 Jan 11 03:25 access-20140111-20140113.log
-rw-r--r--. 1 root   root          0 Jan 13 03:08 access-20140111.log
-rw-r--r--. 1 root   root   10640709 Jan 12 03:08 access-20140112.log
-rw-r--r--. 1 root   root   10069927 Jan 13 03:07 access-20140113.log
-rw-r--r--. 1 root   root     908253 Jan 13 08:59 access.log
-rw-r--r--. 1 root   root     622524 Jan  8 03:39 error-20140108-20140110-20140112.log
-rw-r--r--. 1 root   root          0 Jan 12 03:08 error-20140108-20140110.log
-rw-r--r--. 1 root   root          0 Jan 10 03:38 error-20140108.log
-rw-r--r--. 1 root   root     258401 Jan  9 03:18 error-20140109-20140111-20140113.log
-rw-r--r--. 1 root   root          0 Jan 13 03:08 error-20140109-20140111.log
-rw-r--r--. 1 root   root          0 Jan 11 03:26 error-20140109.log
-rw-r--r--. 1 root   root     291228 Jan 10 03:37 error-20140110-20140112.log
-rw-r--r--. 1 root   root          0 Jan 12 03:08 error-20140110.log
-rw-r--r--. 1 root   root     305361 Jan 11 03:22 error-20140111-20140113.log
-rw-r--r--. 1 root   root          0 Jan 13 03:08 error-20140111.log
-rw-r--r--. 1 root   root     292764 Jan 12 03:04 error-20140112.log
-rw-r--r--. 1 root   root     283243 Jan 13 02:59 error-20140113.log
-rw-r--r--. 1 root   root      30299 Jan 13 08:58 error.log
-rw-r--r--. 1 apache apache      919 Dec 23 08:11 error.php
[root@Webserver-2 logs]#
MadHatter
  • 78,442
  • 20
  • 178
  • 229
Demented
  • 3
  • 1

1 Answers1

1

The problem with your config is that you also rotate log files that already have been rotated by setting the extension .log and your use of the /var/www/html/joomla-1.x/example.com/logs/*.log wildcard.

Either repeat the stanza while explicitely naming /var/www/html/joomla-1.x/example.com/logs/access.log and /var/www/html/joomla-1.x/example.com/logs/error.log or remove the extension .log option.

HBruijn
  • 72,524
  • 21
  • 127
  • 192