LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Ubuntu (http://www.linuxquestions.org/questions/ubuntu-63/)
-   -   logrotate doesnt work properly for virtualhosts (http://www.linuxquestions.org/questions/ubuntu-63/logrotate-doesnt-work-properly-for-virtualhosts-4175435873/)

alireza.kayvan 11-06-2012 05:27 AM

logrotate doesnt work properly for virtualhosts
 
I want to rotate virtualhost logs when it excceded 200M . I created a /etc/logroate.d/vhosts and execute command : logrotate -v -f /etc/logrotate.d/vhosts . it seams every time i run the command all log files rotate. could anyone tell me where the problem is ?



/etc/logroate.d/vhosts :

/var/www/[0-9A-Za-z]*/logs/access_log {
size 200M
missingok
rotate 52
compress
delaycompress
notifempty
create 640 root adm
sharedscripts
postrotate
if [ -f "`. /etc/apache2/envvars ; echo ${APACHE_PID_FILE:-/var/run/apache2.pid}`" ]; then
/etc/init.d/apache2 reload > /dev/null
fi
endscript
}

/var/www/[0-9A-Za-z]*/logs/error_log {
size 200M
missingok
rotate 52
compress
delaycompress
notifempty
create 640 root adm
sharedscripts
postrotate
if [ -f "`. /etc/apache2/envvars ; echo ${APACHE_PID_FILE:-/var/run/apache2.pid}`" ]; then
/etc/init.d/apache2 reload > /dev/null
fi
endscript
}
This is one of my log directories listing:
-rw-r----- 1 root adm 14K 2012-11-06 14:23 access_log
-rw-r----- 1 root adm 8.4K 2012-11-06 13:45 access_log.1
-rw-r----- 1 root adm 531 2012-11-06 13:36 access_log.2.gz
-rw------- 1 www-data www-data 2.6M 2012-11-06 13:24 access_log.3.gz
-rw-r----- 1 root adm 1.9K 2012-11-06 14:20 error_log
-rw-r----- 1 root adm 1.3K 2012-11-06 13:45 error_log.1
-rw-r----- 1 root adm 184 2012-11-06 13:30 error_log.2.gz
-rw------- 1 www-data www-data 491K 2012-11-06 13:21 error_log.3.gz

custangro 11-07-2012 02:04 PM

From the man page...

Code:


-f, --force
              Tells  logrotate  to force the rotation, even if it doesn’t think this is necessary.  Sometimes this is useful after adding new entries to a
              logrotate config file, or if old log files have been removed by hand, as the new files will be created, and logging will continue correctly.

So your original question

Quote:

it seams every time i run the command all log files rotate. could anyone tell me where the problem is ?
There is no problem...the command is running as it should

alireza.kayvan 11-18-2012 12:17 AM

Thank you , yes ,its running correctly , I checked it the days after. it was ok


All times are GMT -5. The time now is 12:57 PM.