日期:2014-05-16 浏览次数:21078 次

/etc/rsyslog.conf
auth : 主要与认证有关的机制 cron : 就是例行性工作调度crontab等生成信息日志的地方 daemon : 就是各个daemon有关的信息 kern : 就是内核(kernel)产生信息的地方 lpr : 打印相关信息 mail : 只要与邮件收发有关的信息记录在此 news : 与新闻组服务器有关的东西
info : 一些基本的信息说明 notice : 除了info还需要注意的一些信息内容 warning : 警示的信息,可能有问题,但是不至于影响到某个daemon的运行 error : 一些重大的错误信息 crit : 比error还要严重的错误信息 alert : 警告,已经很有问题的等级 emerg : “疼痛”等级,意指系统已经几乎要死机状态!
. : 代表比后面还要高的等级(含该等级)都被记录下来的意思。例如:news.err 代表只要是news的信息,而且该信息的等级大于等于error级别就会被记录下来的意思 .= : 代表所需要的等级==后面链接的等级,其它的不要 .! : 代表不等于,即除了该等级之外的等级都记录下来
/etc/init.d/rsyslog restart

#!/bin/sh
# Clean non existent log file entries from status file
cd /var/lib/logrotate
test -e status || touch status
head -1 status > status.clean
sed 's/"//g' status | while read logfile date
do
[ -e "$logfile" ] && echo "\"$logfile\" $date"
done >> status.clean
mv status.clean status
test -x /usr/sbin/logrotate || exit 0
/usr/sbin/logrotate /etc/logrotate.conflogrotate主要是针对日志文件来进行轮替操作,所以它必须记载在什么状态下才将日志文件进行轮替的设置,通过上面的shell脚本,就可以看出配置文件是在/etc/logrotate.conf# see "man logrotate" for details
# rotate log files weekly
weekly <== 默认每个星期进行一次logrotate工作
# keep 4 weeks worth of backlogs
rotate 4 <== 默认没星期保留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 <== 将这个目录下的所有文件都读进来执行rotate程序
# no packages own wtmp, or btmp -- we'll rotate them here
/var/log/wtmp { <== 仅针对/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
compress:通过gzip 压缩转储以后的日志 nocompress:不需要压缩时,用这个参数 copytruncate:用于还在打开中的日志文件,把当前日志备份并截断 nocopytruncate:备份日志文件但是不截断 create mode owner group:转储文件,使用指定的文件模式创建新的日志文件 nocreate:不建立新的日志文件 delaycompress:和 compress 一起使用时,转储的日志文件到下一次转储时才压缩 nodelaycompress:覆盖 delaycompress 选项,转储同时压缩。 errors address:专储时的错误信息