[rt-users] rm sessiondata from crontab...

Wojciech Jedliczka wj at 3v.pl
Fri Jan 18 12:37:54 EST 2002


> I'm trying to get find with -exec to work .. and I'm not getting any
> luck
>
> Thanks
> Kris

Hi,

I had the same problem. My solution:

-----------------------------------

Change through crontab -e :

#0 * * * * find /opt/rt2/WebRT/sessiondata -type f -amin +600 -exec rm '{}'
;
0 * * * * /opt/rt2/bin/rtcron

-----------------------------------

Write a small script "rtcron" :

#
#
# Every hour, delete session files and lockfiles that haven't
# been touched in 10 hours
#

AGEINFO="+600"                      # purge files after 10 hours untouched

CAT="/bin/cat"
RM="/bin/rm"
RM="$RM -f"

JUNK=/tmp/rtjunk$$             # temp file used for file listing

trap "$RM \$JUNK; exit 1" 0 1 2 15
find /opt/rt2/WebRT/sessiondata -type f -amin $AGEINFO -print >$JUNK

if [ -s $JUNK ]; then
   for i in `$CAT $JUNK`; do
#         echo "    $i"
         $RM $i
   done
fi

-----------------------------------

That is all. It works.

Wojtek






More information about the rt-users mailing list