1.常發現log檔太大造成開啟不易可設定檔案大小
修改ee /usr/local/etc/apache22/httpd.conf
ErrorLog "|/usr/local/sbin/rotatelogs /var/log/error自設檔名.log 86400"
#讓HTTPd-eccess.log每個log檔案大小限制為5M
CustomLog "|/usr/local/sbin/rotatelogs /var/log/access自設檔名.log 5M" common
2.再來設置sh檔清除30天前的log檔
ee /usr/local/etc/apache22/lograte.sh
#!/bin/sh
find /var/log/httpd-access.log.* -type f -mtime +30 -exec rm '{}' \;
find /var/log/httpd-error.log.* -type f -mtime +30 -exec rm '{}' \;
apachectl graceful
存檔後
chmod a+x lograte.sh
3.固定時間執行lograte.sh
ee /etc/crontab
* 3 * * 0 root /usr/local/etc/apache22/lograte.sh
沒有留言:
張貼留言