共计 1900 个字符,预计需要花费 5 分钟才能阅读完成。
这篇文章主要介绍了 squid 日志过大怎么处理,具有一定借鉴价值,感兴趣的朋友可以参考下,希望大家阅读完这篇文章之后大有收获,下面让丸趣 TV 小编带着大家一起了解一下。
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 删除分割的日志文件
感谢你能够认真阅读完这篇文章,希望丸趣 TV 小编分享的“squid 日志过大怎么处理”这篇文章对大家有帮助,同时也希望大家多多支持丸趣 TV,关注丸趣 TV 行业资讯频道,更多相关知识等着你来学习!