+
81
-

linux centos如何清理长年累月庞大的日志文件?

请问linux centos如何清理长年累月庞大的日志文件?

网友回复

+
1
-

可以写一个sh批处理命令定时执行

#!/bin/bash
# this script clear logs in Linux (made in CentOS)
cd /var/log
truncate -s 0 /var/log/*log
find . -name "*.gz" -type f -delete
find . -name "*.0" -type f -delete
find . -name "*.1" -type f -delete
find . -name "*.log.*" -type f -delete

我知道答案,我要回答