apache 日志轮询三种方法

日志轮询

方法1

下载cronlog软件

cd /home/lvnian/tools

wget http://down1.chinaunix.net/distfiles/cronolog-1.6.2.tar.gz

tar xf cronolog-1.6.2.tar.gz 

cd cronolog-1.6.2

./configure 

make && make install

ll /usr/local/sbin/cronolog

#######3

cronlog系统自带方式.把httpd.conf或者httpd.vhost.conf中的access访问日志改成下面的内容

###按天轮询

CustomLog "|/usr/local/sbin/cronolog /application/apache/logs/www.access_%Y%m%d.log" combined

##按周轮询

##CustomLog "|/usr/local/sbin/cronolog /application/apache/logs/www.access_%w.log" combined

##按小时轮询

##CustomLog "|/usr/local/sbin/cronolog /application/apache/logs/www.access_%Y%m%d%H.log" combined

#########结果

[root@A_WEB logs]# ll /application/apache/logs/

total 52

-rw-r--r-- 1 root   root   598 Sep 21 10:50 www.access_20150921.log



###方法2

##系统自带的rotatelogs

###把httpd.conf或者httpd.vhost.conf中的access访问日志改成下面的内容

CustomLog "| /application/apache/bin/rotatelogs /application/apache/logs/www.access_%Y%m%d.log 86400" combined

##重启http服务就可以了


/application/apache/bin/apachectl -t

/etc/init.d/httpd restart

netstat -lnt

ll /application/apache/logs



方法3:

定时任务切割

cd /application/apache/logs/

mv www-access.log www-access_$(date +%F).log

/application/apache/bin/apachectl graceful


你可能感兴趣的:(日志轮询)