[ic] Purging session/ and tmp/ - expireall, or rm?

Grant listbox at email.com
Fri Nov 21 11:37:47 EST 2003


> Quoting ICdev (interchange.mail at virgin.net):
> > Hey,
> >
> > I'm not quite clear on which method I should use in crontab to
> clear the
> > contents of the 'session' and 'tmp' directories.
> >
> > In the icadvanced document, it says that if you're using DBM
> sessions, you
> > should use expireall. I am using standard session files, but
> having searched
> > the archives, people seem to be using expireall or plain old rm
> arbitrarily,
> > or even both, one after the other!
> >
> > So, which of the following should I use?:
> >
> > 20 4 * * * su -c "/usr/lib/interchange/bin/expireall -r" interch
> >
> > or
> >
> > 20 4 * * * find /var/lib/interchange/store_name/session -type f
> -mtime +2 |
> > xargs rm -fv
> > 20 4 * * * find /var/lib/interchange/store_name/tmp -type f
> -mtime +2 | xargs
> > rm -fv
> >
> > , or doesn't it matter? Shouldn't the parent directories of the
> session files
> > be deleted too?
> >
> > I tried expireall manually - it took its time executing, but
> didn't seem to
> > have any affect on the stuff in session and tmp; I'm guessing
> that's because
> > it's less than a day old.
> >
> > *Finally*, what if someone is placing an order just as their
> session files are
> > deleted with rm?
>
> I use a very simple little script I call clean_session_tmp to do it:
>
> #!/bin/sh
>
> for DIR in $*
> do
>         for i in session tmp
>         do
>             if test -d $DIR/$i
>             then
>                 find $DIR/$i -type f -mmin +480 | xargs
> --no-run-if-empty rm
>                 find $DIR/$i -type d -empty -depth -mindepth 1 |
> xargs --no-run-if-empty rmdir
>             else
>                 echo "$0: $DIR/$i doesn't exist."
>             fi
>         done
> done
>
> The 480 is 8 hours. You can change the number to what you want.
>
> It is called in cron:
>
> 22 4 * * * /usr/local/interchange/bin/clean_session_tmp /home/*/catalogs/*

I set this up and when running the following command:

~/ic/bin/clean_session_tmp ~/catalogs/mycat

I get the following error:

Missing $ on loop variable at /the/path/ic/bin/clean_session_tmp line 3.

Examining the file with vi, it looks identical to Mike's.  What did I screw
up?  Also, what is the proper chmod for this file?

- Grant



More information about the interchange-users mailing list