Home > Database > Mysql Tutorial > body text

利用cronolog来做log转换

WBOY
Release: 2016-06-07 15:06:37
Original
1338 people have browsed it

利用 cronolog来做log 转换 .. http://www.cronolog.org/ 获取新的cronolog 编译.安装 把CustomLog /usr/local/apache1.3/logs/access_log common 改成 CustomLog "|/usr/local/sbin/cronolog /usr/local/apache1.3/logs/access_log_%w" common 把ErrorLog /

利用cronolog来做log转换..

http://www.cronolog.org/

获取新的cronolog

编译.安装

把CustomLog /usr/local/apache1.3/logs/access_log common

改成

CustomLog "|/usr/local/sbin/cronolog /usr/local/apache1.3/logs/access_log_%w" common

把ErrorLog /usr/local/apache1.3/logs/error_log

改成

ErrorLog "|/usr/local/sbin/cronolog /usr/local/apache1.3/logs/error_log_%w"

注:上面的%w表示一年中的第几个星期,更多信息看man cronolog,这样每周就会有新的log了..

然后重新运行apache.用graceful参数:

/usr/local/apache/bin/apachectl graceful

用vi编辑一个简单的脚本

#!/bin/bash

find /usr/local/apache/logs/access* -mtime +31 -exec rm -f {} \;

find /usr/local/apache/logs/error* -mtime +31 -exec rm -f {} \;

/usr/local/apache/bin/apachectl graceful

这个脚本的作用是让系统自动删除一个月前修改过的文件

然后vi /etc/crontab

添加一行

* 3 * * 6 root /usr/local/apache/htdocs/ww/baksh/lograte.sh

这个表示刚才编辑的脚本在每周6的3点运行

附:crontab中五个*的含义。。。。



(0-59)

小時

(0-23)

日期

(1-31)

月份

(1-12)



(0-6)
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template