/1 /usr/bin/sh /data/scripts/remove_log.sh
[root@VM_0_10_centos ~]# more /data/scripts/remove_log.sh
#!/bin/bash
echo "检查时间:" date
dir=`du -s /data/|sort -nr | head -n 2|awk -F " " ‘{print $2}‘<br/>disk_usage=
df -h|grep /dev/vd|awk -F " " ‘{print $5}‘|awk -F " " ‘{print $1}‘|grep -oP ‘[0-9]‘`
echo "当前使用空间:" $disk_usage "%"
if [ "$disk_usage" -gt "80" ];then
echo "需要删除"
find $dir -type f -mtime +90 -name .txt|xargs rm -f
#删除磁盘使用率前2的
else
echo "不超过 80% 无需删除"
fi
原文:https://blog.51cto.com/11676712/2531040