squid日志过大怎么处理
这篇文章主要介绍了squid日志过大怎么处理,具有一定借鉴价值,感兴趣的朋友可以参考下,希望大家阅读完这篇文章之后大有收获,下面让小编带着大家一起了解一下。
创新互联专注于奇台企业网站建设,成都响应式网站建设,商城开发。奇台网站建设公司,为奇台等地区提供建站服务。全流程定制开发,专业设计,全程项目跟踪,创新互联专业和态度为您提供的服务
Squid 默认的5天会压缩一次, 在 /etc/logrotate.d/squid中有设置。如果你修改了日志的位置,
请修改 /etc/logrotate.d/squid
/home/log/squid/access.log {
weekly
rotate 5
copytruncate
compress
notifempty
missingok
}
/home/log/squid/cache.log {
weekly
rotate 5
copytruncate
compress
notifempty
missingok
}
/home/log/squid/store.log {
weekly
rotate 5
copytruncate
compress
notifempty
missingok
# This script asks squid to rotate its logs on its own.
# Restarting squid is a long process and it is not worth
# doing it just to rotate logs
postrotate
/usr/sbin/squid -k rotate
endscript
}
首先修改squid.conf
logfile_rotate 3(保留几份日志)
修改/etc/crontab
0 0 * * * squid /home/squid/sbin/squid -k rotate
(每天压缩一次)
crontab /etc/crontab (crontab生效)
Squid 默认的5天会压缩一次, 在 /etc/logrotate.d/squid中有设置。如果你修改了日志的位置,
请修改 /etc/logrotate.d/squid
/home/log/squid/access.log {
weekly
rotate 5
copytruncate
compress
notifempty
missingok
}
/home/log/squid/cache.log {
weekly
rotate 5
copytruncate
compress
notifempty
missingok
}
/home/log/squid/store.log {
weekly
rotate 5
copytruncate
compress
notifempty
missingok
# This script asks squid to rotate its logs on its own.
# Restarting squid is a long process and it is not worth
# doing it just to rotate logs
postrotate
/usr/sbin/squid -k rotate
endscript
}
首先修改squid.conf
logfile_rotate 3(保留几份日志)
修改/etc/crontab
0 0 * * * squid /home/squid/sbin/squid -k rotate
(每天压缩一次)
crontab /etc/crontab (crontab生效)
配置了SQUID认证后,SQUID的日志文件爆炸式增长,主要为access.log和cache.log所以为了能够及时清理日志文件,使用如下方法:
SQUID提供了日志分割命令,squid -k rotate ,通过这个命令可以将日志文件分割为access.log.0
access.log.1 ..... cache.log.0 cache.log.1 ..... 这样可以通过调用corntab
命令来定时分割日志文件,再配合rm命令来定时删除这些个日志文件。
50 7 * * * /usr/local/squid2.7/sbin/squid -k rotate #每日7:50分割日志文件
00 8 * * * rm -f /usr/local/squid2.7/var/logs/access.log.*
00 8 * * * rm -f /usr/local/squid2.7/var/logs/store.log.*
#每日8:00删除分割的日志文件
感谢你能够认真阅读完这篇文章,希望小编分享的“squid日志过大怎么处理”这篇文章对大家有帮助,同时也希望大家多多支持创新互联,关注创新互联行业资讯频道,更多相关知识等着你来学习!
名称栏目:squid日志过大怎么处理
网站链接:http://scjbc.cn/article/gjjgse.html