Question

On my CentOS 6.5,

A couple of sites are running and I set logs directory separately. loglotate works weekly but the results is not good. it archive already archived logs again every week.

here is /etc/logrotate.d/sites file.

/home/site1/logs/httpd/* /home/site2/logs/ httpd/* /home/site3/logs/httpd/* {
    copytruncate
    weekly
    rotate 4
    missingok
    notifempty
    dateext
}

and file list on /home/siate1/logs/httpd

-rw-r--r-- 1 root root  35100863 May 14 17:37 site1-access_log
...
-rw-r--r-- 1 root root         0 Apr 27 03:29 site1-access_log-20140413-20140420
-rw-r--r-- 1 root root         0 May  4 03:24 site1-access_log-20140413-20140420-20140427
-rw-r--r-- 1 root root         0 May 11 03:35 site1-access_log-20140413-20140420-20140427-20140504
-rw-r--r-- 1 root root  70221784 May 11 03:35 site1-access_log-20140413-20140420-20140427-20140504-20140511
-rw-r--r-- 1 root root         0 Apr 27 03:29 site1-access_log-20140420
-rw-r--r-- 1 root root         0 May  4 03:24 site1-access_log-20140420-20140427
-rw-r--r-- 1 root root         0 May 11 03:35 site1-access_log-20140420-20140427-20140504
-rw-r--r-- 1 root root  69335598 May 11 03:35 site1-access_log-20140420-20140427-20140504-20140511
-rw-r--r-- 1 root root         0 May  4 03:24 site1-access_log-20140427
-rw-r--r-- 1 root root         0 May 11 03:35 site1-access_log-20140427-20140504
-rw-r--r-- 1 root root  68505478 May 11 03:35 site1-access_log-20140427-20140504-20140511
-rw-r--r-- 1 root root         0 May 11 03:35 site1-access_log-20140504
-rw-r--r-- 1 root root  68772871 May 11 03:35 site1-access_log-20140504-20140511
-rw-r--r-- 1 root root  68054687 May 11 03:35 site1-access_log-20140511
-rw-r--r-- 1 root root     24701 May 14 16:54 site1-error_log
...
-rw-r--r-- 1 root root         0 Apr 27 03:29 site1-error_log-20140413-20140420
-rw-r--r-- 1 root root         0 May  4 03:24 site1-error_log-20140413-20140420-20140427
-rw-r--r-- 1 root root         0 May 11 03:35 site1-error_log-20140413-20140420-20140427-20140504
-rw-r--r-- 1 root root 109645452 May 11 03:35 site1-error_log-20140413-20140420-20140427-20140504-20140511
-rw-r--r-- 1 root root         0 Apr 27 03:29 site1-error_log-20140420
-rw-r--r-- 1 root root         0 May  4 03:24 site1-error_log-20140420-20140427
-rw-r--r-- 1 root root         0 May 11 03:35 site1-error_log-20140420-20140427-20140504
-rw-r--r-- 1 root root     43345 May 11 03:35 site1-error_log-20140420-20140427-20140504-20140511
-rw-r--r-- 1 root root         0 May  4 03:24 site1-error_log-20140427
-rw-r--r-- 1 root root         0 May 11 03:35 site1-error_log-20140427-20140504
-rw-r--r-- 1 root root     84371 May 11 03:35 site1-error_log-20140427-20140504-20140511
-rw-r--r-- 1 root root         0 May 11 03:35 site1-error_log-20140504
-rw-r--r-- 1 root root     38442 May 11 03:35 site1-error_log-20140504-20140511
-rw-r--r-- 1 root root     31182 May 11 03:35 site1-error_log-20140511

What is the problem?

Was it helpful?

Solution

Your match is too broad. It should not match rotated files, but only the current logfile for each rotation group. Try logs/httpd/*_log rather than logs/httpd/* (if all log files actually end in _log). Refer to man 7 glob for details.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top