httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From DeAnna.Clem...@McKGenMed.com
Subject rotate logs
Date Fri, 23 Aug 2002 13:40:41 GMT


Do you need to stop the apache process to rotate logs?  Some documentation
I read indicated you had to and some didn't.  I did find this script on the
Sun site.  It just appears to copy and compress the logs and then performs
a touch to 0 it out.  Any thoughts or experience with this?

###########################################################################
#!/usr/bin/bash

###
# rotate_apache
#
# Rotate apache server logs.
# Finds the 'access_log' and 'error_log' in
# the apache directory and duplicates and
# compresses them.
#
# Can be run as a cron job
#
# Submitted by: Robert Banniza robert@rootprompt.net

### Vars used throughout - adjust as needed
DATE=`date +%d%h-1.1p`
#HOMEDIR='/users/u1'
HOMEDIR='/usr/local'
LOGS='access_log
error_log'


# main.

for h in $(ls $HOMEDIR);
do
             for i in $LOGS;
             do
                         if [ -f $HOMEDIR/$h/logs/$i ]; then
                                     cp $HOMEDIR/$h/logs/$i
$HOMEDIR/$h/logs/$i.$DATE
                                     touch $HOMEDIR/$h/logs/$i
                                     gzip $HOMEDIR/$h/logs/$i.$DATE
                         fi

                         # search and destroy.
                         find $HOMEDIR/$h/logs -name $i.* -a -mtime +30
-exec rm {} \;

             done
done






---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org





---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Mime
View raw message