linux删除第几天日志【原创】

cat del.sh

#!/bin/bash

thirty=`date -d '30days ago' +%Y-%m-%d`
cd $1

#删除输入路径下第30天的日志文件
find . -name "*$thirty*" -type f | xargs -I {} rm -f {}

利用crontab每天执行,每天删除据现在第30天的日志

40 1 * * * /usr/local/cleanlog/del.sh

 

欢迎转载,请注明出处

posted @ 2017-08-28 16:21  paul_hch  阅读(155)  评论(0编辑  收藏  举报