[ic] Purging session/ and tmp/ - expireall, or rm?
mike at perusion.com
Thu Nov 20 23:41:40 EST 2003
Quoting ICdev (interchange.mail at virgin.net):
> 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
> 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:
for DIR in $*
for i in session tmp
if test -d $DIR/$i
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
echo "$0: $DIR/$i doesn't exist."
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/*
Perusion -- Expert Interchange Consulting http://www.perusion.com/
phone +1.765.647.1295 <mike at perusion.com>
Function in chaos, finish in style. -- Unknown
More information about the interchange-users