On 8/13/08, Zbigniew Szalbot <z.szalbot@xxxxxxxxxxx> wrote:> Hello,>> I fear it it not possible but I'll ask the experts anyway. Is it possible to rotate apache logs based on size and time?>> I would like to rotate logs every 20MB AND at the start of the month irrespective of the log size.>> Is it possible? yes its possibleyou would just need to add in your /etc/logrotate.conf the following content : "/websites/domain.com/logs/domain.com.sys.qualiproj.access_log"/websites/domain.com/logs/domain.com.sys.qualiproj.error_log {rotate 4size= 50sharedscriptspostrotate/sbin/killall -HUP httpdendscript} i kind of written a small scrit to add /delete /edit thelogrotate.conf for virtual domains ( i give no grauntee that it willwork for you ) ( suggestion welcomed ) #!/bin/bashclear add_log_rotation (){read -p "Enter your domain name: " dread -p "Enter the number of times you want logs to be rotated : " rread -p "Enter the size of you log size " s tmp=` echo $d |sed s/\.com//g ` config_file="/etc/logrotate.conf" if [ -d /websites/"$d" ]; then if [ -z "$(sed -n"/\#apache_logs_${d}\#/,/\#apache_logs_${d}\#/p" /etc/logrotate.conf)" ]; then cat >> $config_file << _eof_######################apache_logs_$d###########################"/websites/$d/logs/$tmp.sys.qualiproj.access_log"/websites/$d/logs/$tmp.sys.qualiproj.error_log { rotate $r size= $s sharedscripts postrotate /sbin/killall -HUP httpd endscript }#####################apache_logs_$d###########################_eof_ elseecho -e "logrotate for this domian already exist" fielseecho -e " the domain does not exist "fi} delete_log_rotation (){read -p "Enter your domain name: " dtmp=`echo $domain |sed s/\.com//g ` if [ -d /websites/"$d" ]; then if [ -n "$(sed -n"/\#apache_logs_${d}\#/,/\#apache_logs_${d}\#/p" /etc/logrotate.conf)" ]; then sed -i "/\#apache_logs_${d}\#/,/\#apache_logs_${d}\#/d" /etc/logrotate.conf elseecho -e "log rotate does not exist for this domain" fielseecho -e "The domain does not exist"fi} edit_log_rotation (){read -p "Enter your domain name: " dread -p "Edit the number of times you want logs to be rotated : " rread -p "Edit the size of your log sise " stmp=`echo $domain |sed s/\.com//g ` if [ -d /websites/"$d" ]; then if [ -n "$(sed -n"/\#apache_logs_${d}\#/,/\#apache_logs_${d}\#/p" /etc/logrotate.conf)" ]; then sed -i "/\#apache_logs_${d}\#/,/\#apache_logs_${d}\#/d" /etc/logrotate.conf cat >> $config_file << _eof_######################apache_logs_$d###########################"/websites/$d/logs/$tmp.sys.qualiproj.access_log"/websites/$d/logs/$tmp.sys.qualiproj.error_log { rotate $r size=$s sharedscripts postrotate /sbin/killall -HUP httpd endscript }#####################apache_logs_$d###########################_eof_ elseecho -e "log rotate does not exist for this domain" fielseecho -e "The domain does not exist"fi} read -p "Do you want to add, delete, or edit the logs rotation: " l case $l inadd ) add_log_rotation;;delete ) delete_log_rotation;;edit ) edit_log_rotation;;* ) echo -e "Please type add delete or edit"esac done!! -- सादरअग्नेल्लो द्सौज़ाwww.linux-vashi.blogspot.comwww.bible-study-india.blogspot.com