您好,登录后才能下订单哦!
这篇文章主要介绍了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日志过大怎么处理”这篇文章对大家有帮助,同时也希望大家多多支持亿速云,关注亿速云行业资讯频道,更多相关知识等着你来学习!
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。