Linux实用程序logrotate定期重命名和重用系统错误日志文件,以便它们不占用过多的磁盘空间. Linux系统将有关此内容的所有相关信息存储到文件/etc/logrotate.conf中

有许多属性可以帮助我们管理日志大小.在做任何事情之前,请阅读手册(“man logrotate”).在我的机器上,此文件如下所示:

# 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

# packages drop log rotation information into this directory

include /etc/logrotate.d

# no packages own wtmp, or btmp -- we'll rotate them here

/var/log/wtmp {

missingok

monthly

create 0664 root utmp

rotate 1

}

/var/log/btmp {

missingok

monthly

create 0660 root utmp

rotate 1

}

# system-specific logs may be configured here

我们可以看到日志文件将每周轮换一次.这可能会更改为每日.我的机器上没有启用压缩.如果要使日志文件较小,可以启用此功能.

有一个很好的article,你可能想要参考完全理解这个主题.

Logo

更多推荐