Ubuntu-12.04

Ubuntu 12.04 中的 Squid3 logrotate 錯誤

  • July 11, 2014

在 Ubuntu 12.04 伺服器中,Squid3 的 logrotate 不起作用。當我注意到分區已從 squid3 日誌中填滿時,我發現了問題。強制 logrotate 會產生以下錯誤:

~# logrotate -f /etc/logrotate.d/squid3
error: error running shared prerotate script for '/var/log/squid3/*.log

這是完整的調試輸出:

~# logrotate -f /etc/logrotate.d/squid3 -d
reading config file /etc/logrotate.d/squid3
reading config info for /var/log/squid3/*.log

Handling 1 logs

rotating pattern: /var/log/squid3/*.log  forced from command line (2 rotations)
empty log files are rotated, old logs are removed
considering log /var/log/squid3/access.log
 log needs rotating
considering log /var/log/squid3/cache.log
 log needs rotating
rotating log /var/log/squid3/access.log, log->rotateCount is 2
dateext suffix '-20140312'
glob pattern '-[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]'
previous log /var/log/squid3/access.log.1 does not exist
renaming /var/log/squid3/access.log.2.gz to /var/log/squid3/access.log.3.gz (rotatecount 2, logstart 1, i 2),
renaming /var/log/squid3/access.log.1.gz to /var/log/squid3/access.log.2.gz (rotatecount 2, logstart 1, i 1),
renaming /var/log/squid3/access.log.0.gz to /var/log/squid3/access.log.1.gz (rotatecount 2, logstart 1, i 0),
rotating log /var/log/squid3/cache.log, log->rotateCount is 2
dateext suffix '-20140312'
glob pattern '-[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]'
previous log /var/log/squid3/cache.log.1 does not exist
renaming /var/log/squid3/cache.log.2.gz to /var/log/squid3/cache.log.3.gz (rotatecount 2, logstart 1, i 2),
renaming /var/log/squid3/cache.log.1.gz to /var/log/squid3/cache.log.2.gz (rotatecount 2, logstart 1, i 1),
renaming /var/log/squid3/cache.log.0.gz to /var/log/squid3/cache.log.1.gz (rotatecount 2, logstart 1, i 0),
running prerotate script
running script (multiple) with arg /var/log/squid3/*.log : "
               test ! -x /usr/sbin/sarg-reports || /usr/sbin/sarg-reports
              "
renaming /var/log/squid3/access.log to /var/log/squid3/access.log.1
renaming /var/log/squid3/cache.log to /var/log/squid3/cache.log.1
running postrotate script
running script (multiple) with arg /var/log/squid3/*.log : "
               test ! -e /var/run/squid3.pid || /usr/sbin/squid3 -k rotate
"
removing old log /var/log/squid3/access.log.3.gz
error: error opening /var/log/squid3/access.log.3.gz: file or directory not found

知道可以在這裡檢查什麼嗎?謝謝。

prerotate如日誌條目所示,腳本存在錯誤。

要調試這一點,可以從配置中刪除腳本,然後將它們一一添加,直到找到麻煩的腳本。

它們也可以手動執行以查看哪個失敗,但在這種情況下,OP 說它們默默地失敗了。

使用logrotate -vf /etc/logrotate.d/squid3(-v for vervose,-f for force)是另一種選擇,在這種情況下有助於獲取有關問題的數據。

可以在此處找到有關 logrotate 的良好文件:

引用自:https://serverfault.com/questions/581299