linux系统日志不自动切分的问题

时间: 2010-08-09 / 分类: Parallels / 浏览次数: 16 views / 0个评论 发表评论

在/var/log下的日志,每7天将切分log,原有log命名为xxx.1,并且累积到一个月后自动删除。但是有的服务器不切分log。

解决方案
log切分是由 /etc/cron.daily/logrotate 完成的。他的配置文件是:

/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
}

# system-specific logs may be also be configured here.
—————————————————–

这个文件指定了切分周期等参数。具体对每一个log的切分,是由/etc/logrotate.d目录下的脚本完成的。这个目录下包含apache、mysql、resin等若干服务的log文件。(邮件的/var/log/maillog是使用syslog写入系统的)

手工运行/etc/cron.daily/logrotate ,看报告什么错误。

例如报告
error: httpd:1 duplicate log entry for /var/log/httpd/access_log

这是由于在/etc/logrotate.d目录下存在重复项目造成的。经检查用户自行安装了httpd的rpm,所以在etc/logrotate.d目录下存在apache和httpd两个目录切分项目,造成了logrotate程序运行失败。

解决方法:移出/etc/logrotate.d/httpd文件即可。推荐按照一台干净的服务器,检查是否有多余的log切分项目。

订阅

发表评论

你必须 登录后 才能留言!