proxy代理   soft软件   IT 业界特快   norton 诺顿病毒库   代理列表   search FTP搜索   whois IP地理位置   blog 追求完美  
money理财   life生活   RSS聚合门户   firefox WEB浏览器   免费域名   typeset 假古文   AntiVirus 反病毒   ipcn 站点导航  

« fd | Main | HTTP 1.0/1.1 »

January 5, 2005

logrotate on demand~

版权声明:可以任意转载,转载时请务必以超链接形式标明文章原始出处和作者信息及本声明。
https://windtear.net/archives/2005/01/05/000546.html

尽管我不喜欢它
但不可否认logrotate还是具有足够的广泛性和应用

squid httpd proftpd ...
等等这些大服务
log的增长是恐怖的
logrotate不好的地方就在于它是copy方式处理
而我宁愿mv改名 再送一个HUP信号过去

如果采用 logrotate 的话 需要写一个配置文件
具体配置文件怎么写 可以 man logrotate 查看
里面有重足的解释和样例
LOGROTATE(8) System Administrator's Manual LOGROTATE(8)

NAME
logrotate - rotates, compresses, and mails system logs

SYNOPSIS
logrotate [-dv] [-f|--force] [-s|--state file] config_file+
......

/etc/logrotate.conf 和 /etc/logrotate.d/ 是默认的配置文件和目录

% cat /etc/logrotate.conf
# see "man logrotate" for details
# rotate log files weekly
weekly

# keep 4 weeks worth of backlogs
rotate 4

# create new (empty) log files after rotating old ones
create

# uncomment this if you want your log files compressed
#compress

# RPM packages drop log rotation information into this directory
include /etc/logrotate.d

# no packages own wtmp -- we'll rotate them here
/var/log/wtmp {
monthly
create 0664 root utmp
rotate 1
}

% cat /etc/logrotate.d/httpd
/var/log/httpd/*log {
missingok
notifempty
sharedscripts
postrotate
/bin/kill -HUP `cat /var/run/httpd.pid 2>/dev/null` 2> /dev/null || true
endscript
}

这是我改用"mv 结合 squid 自身的 rotate 之前曾用过的logrotate处理方式

/usr/sbin/logrotate /etc/squid/logrotate.conf

% cat /etc/squid/logrotate.conf
/opt/old_access/access.log.bak {
daily
rotate 79
olddir /opt/old_access
size 1M
copytruncate
compress
notifempty
missingok
}

这是另一个
/opt/ipcn/proxy/log/proxy.log {
rotate 9
missingok
size=100M
create 0644
postrotate
/bin/kill -HUP `cat /var/run/proxy/proxy.pid 2> /dev/null` 2> /dev/null || true
endscript
}

如今 squid apache proftpd ... 我都尽量手工去mv 然后HUP 达到rotate的目的
不太爱用 logrotate了

写一下以表示对其历史地位的尊重
logrotate on demand~

本blog WWW

Posted by windtear at January 5, 2005 8:49 PM

本站使用中的任何问题,请与 windtear @ windtear.net 联系
Copyright© 1999-2024 Windtear. All rights reserved.