首页 > Linux考试认证

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

时间:2010-08-13 07:08:27  作者:  我要投稿
Linux初探欢迎您的投稿,投放方法请点击这里查看,我们会定期赠送精美小礼品给优秀的投稿作者。海纳百川 取则行远!LinuxGoo欢迎您的到来。
来源:赛迪网2010/8/10【考试大:中国教育考试第一门户】模拟考场视频课程字号:T T[导读]在/var/log下的日志,每7天将切分log,原有log命名为xxx.1,并且累积到一个月后......
来源:赛迪网 2010/8/10 【考试大:中国教育考试第一门户】 模拟考场 视频课程 字号:T T [导读]在/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切分项目。

  编辑特别推荐:

  全面讲解Linux防火墙入门知识

如果您需转载 linux系统日志不自动切分的问题,请注明来自LinuxGoo.com,其版权归原作者所有。请广大网友留言时遵纪守法,使用文明用语。如果您在应用中有什么问题,请在下面留言,我们会尽快解答。
来顶一下
近回首页
返回首页
发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表
相关文章
栏目热门