shell脚本删除log日志


删除log文件简单shell脚本

  经常会遇到日志把磁盘占满的情况,引起低级故障。我个人在实际工作中,尝试了如下的方法,比较简单,而且快捷有效。

#!/bin/bash
# /root/log_delete.sh
dir_log_1="/home/log/log1"
dir_log_2="/home/log/log2"
dir_log_3="/home/log/log3"

if  [ -d "${dir_log_1}" ]; then 
    find "${dir_log_1}"/* -name '*.txt' -mtime +14 -exec rm -rf {} \;
fi

if  [ -d "${dir_log_2}" ]; then 
    find "${dir_log_2}"/* -name '*.txt' -mtime +14 -exec rm -rf {} \;
fi

if  [ -d "${dir_log_3}" ]; then 
    find "${dir_log_3}"/* -name '*.txt' -mtime +14 -exec rm -rf {} \;
fi


chmod +x /root/log_delete.sh
sh /root/log_delete.sh

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM