Logrotate Cheatsheet
使用
直接在配置文件目录加入配置文件即可工作。
/etc/logrotate.d/
加入后可以立即测试配置文件的正确性
logrotate -d <配置文件>
示例
/var/log/nginx/*.log {
daily
missingok
rotate 52
compress
delaycompress
notifempty
create 640 nginx adm
sharedscripts
postrotate
if [ -f /var/run/nginx.pid ]; then
kill -USR1 `cat /var/run/nginx.pid`
fi
endscript
}
/data/prd/yhservice/logs/g*.log
/data/prd/yhservice/logs/y*.log
{
daily
rotate 30
copytruncate
create 644 oracle oinstall
notifempty
dateext
dateformat -%Y%m%d
}
/data/prd/yhservice/logs/super*.log
{
daily
rotate 30
copytruncate
create 644 root root
notifempty
dateext
dateformat -%Y%m%d
}