【问题标题】:pfSense Squid Rotate Log at Certain Size - Shell ScriptpfSense Squid 以特定大小旋转日志 - Shell 脚本
【发布时间】:2015-02-19 02:16:57
【问题描述】:

尝试在每天凌晨 4 点为 cron 创建一个 shell 脚本,该脚本将读取 squid 的 access.log 文件的大小,并在超过一定大小 (20MB) 时旋转它。这是我目前所拥有的:

#!/bin/sh

ymd=$(date '+%Y-%m-%d')
file=/var/squid/logs/access.log
minimumsize="20000000"
eval $(stat -s /var/squid/logs/access.log)

if [ $st_size > $minimumsize ]; then
    cp /var/squid/logs/access.log /var/squid/logs/access_log_history/access.log.${ymd}
    rm -fr /var/squid/logs/access.log
    squid -k rotate
else
    :
fi

shell 脚本运行但只是旋转日志文件而不考虑大小并创建一个名为“20000000”的文件。这就对了。我哪里错了?

【问题讨论】:

    标签: shell freebsd squid pfsense


    【解决方案1】:

    与其编写自己的 shellscript,不如看看 newsyslog(8),它做同样的事情。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-10-26
      • 2018-01-20
      • 2018-11-14
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多