您好,登錄后才能下訂單哦!
這篇文章主要介紹了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進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。