用途
在Centos系统中,logrotate可根据用户配置的规则检测和处理日志文件,配合Cron让处理定时化。
组成
/usr/bin/logrotate程序位置/etc/cron.daily/logrotate定时任务执行脚本/etc/logrotate.conf全局配置文件/etc/logrotate.d应用配置文件存放目录,覆盖全局配置
配置说明
weekly每周处理日志rotate 4保留4个日志文件create创建新的日之间dateext默认未加时间戳compress默认不压缩
Nginx日志管理
配置文件
/data/wwwlogs/*nginx.log {
daily
rotate 30
missingok
dateext
compress
notifempty
sharedscripts
postrotate
[ -e /var/run/nginx.pid ] && kill -USR1 cat /var/run/nginx.pid
endscript
}
定时执行
- 路径
/etc/cron.daily/logrotate - shell脚本
#!/bin/sh
/usr/sbin/logrotate -s /var/lib/logrotate/logrotate.status /etc/logrotate.conf
EXITVALUE=$?
if [ $EXITVALUE != 0 ]; then
/usr/bin/logger -t logrotate "ALERT exited abnormally with [$EXITVALUE]"
fi
exit 0
该博客介绍了系统日志管理相关内容。其用途是可按用户规则检测和处理日志文件并定时化。组成包括程序位置、定时任务脚本等。配置说明为每周处理日志,保留4个文件等。还提及Nginx日志管理,包含配置文件、定时执行及路径等信息。
2万+

被折叠的 条评论
为什么被折叠?



