--- elwix/config/etc/uboot/rc.cleaner 2014/01/23 09:24:03 1.1 +++ elwix/config/etc/uboot/rc.cleaner 2014/09/15 19:06:47 1.2 @@ -0,0 +1,27 @@ +#!/bin/sh +# +# (C)`08 AITNET ltd - Sofia/Bulgaria - office@aitbg.com +# by Michael Pounov +# +# example for cron: 0 0 * * * /etc/rc.cleaner >/dev/null +# +# rc.cleaner [+days_after_now] +# +# $Id: rc.cleaner,v 1.2 2014/09/15 19:06:47 misho Exp $ +# + +# +10 files oldes 10 days, -10 files newest 10 days, 10 only created before 10 days +PERIOD="+10" + +if [ -z $1 ]; then + echo "Not specified directory for clean ..." + exit +else + DIR=$1 + PERIOD=${2:-"${PERIOD}"} +fi + +/usr/bin/find $DIR -type f -ctime $PERIOD -exec rm -f {} \; >/dev/null 2>&1 +/usr/bin/find $DIR -type d -ctime $PERIOD -exec rm -fr {} \; >/dev/null 2>&1 + +exit 0