首页 > 其他 > 详细

clean.sh

时间:2019-02-03 11:57:15      阅读:218      评论:0      收藏:0      [点我收藏+]

30 1 * * * /ecapp/soft/ECShellScript/clean/clean.sh >> /ecapp/soft/ECShellScript/clean/logs/clean.`date +\%Y-\%m-\%d`.log 2>&1

 

ls -lR /ecapp/soft|grep ‘^/ecapp/soft‘|grep -E "\/logs:$"

 

[ecwbs@ecapp90 clean]$ cat cleanlist

/ecapp/soft/ECShellScript/clean/logs

/ecapp/soft/zabbix_agent/logs

  

[ecwbs@ecapp91 clean]$ cat clean.sh 

#!/bin/sh

 

echo "cleaning logs start......"

 

filepath="/ecapp/soft/ECShellScript/clean/cleanlist"

 

for fs in $( cat $filepath )

do

        echo "clean "$fs

        find $fs -name \*20*.gz -mtime +30 -exec rm {} \;

done

 

for fz in $( cat $filepath )

do

        echo "gzip "$fz

        find $fz -name \*20*[a-y,0-9] -type f -mtime +1 -exec /usr/bin/gzip -9 {} \;

done

 

exit 0 

 

 

ls -lR /apache|grep ‘^/apache‘|grep -E "\/logs:$"

30 1 * * * /apache/ECShellScript/clean/clean.sh >> /apache/ECShellScript/clean/logs/clean.`date +\%Y-\%m-\%d`.log 2>&1

 

[ecwbl01@secweb3 clean]$ cat clean.sh 

#!/bin/sh

 

echo "cleaning logs start......"

 

filepath="/apache/ECShellScript/clean/cleanlist"

 

for fs in $( cat $filepath )

do

        echo "clean "$fs

        find $fs -name \*20*.gz -mtime +30 -exec rm {} \;

done

 

for fz in $( cat $filepath )

do

        echo "gzip "$fz

        find $fz -name \*20*[a-y,0-9] -type f -mtime +1 -exec /usr/bin/gzip -9 {} \;

done

 

exit 0

 

clean.sh

原文:https://www.cnblogs.com/charon2/p/10349810.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!