If you have DBM capability and MiniVend is using it to store the sessions, you should periodically expire old sessions to keep the session database file from growing too large.
expire -c catalog
There is also an expireall
script which reads all catalog entries in minivend.cfg
and runs expire
on them.
The expire
script accepts a -r
option which tells it to recover lost disk space.
On UNIX, you could add a crontab entry such as the following:
# once a day at 4:40 am 40 4 * * * perl /home/minivend/bin/expireall -r
MiniVend will wait until the current transaction is finished before expiring, so you can do this at any time without disabling web access. Any search paging files for the affected session (kept in ScratchDir) will be removed as well.
With Windows or other operating systems which don't fork(),
you will need to stop the server before running expire
-- this will prevent corruption of the database.
If you are not running DBM sessions, you can use a perl script to delete all files not modified in the last one or two days. The following will work if given an argument of your session directory or session files:
#!perl # expire_sessions.pl -- delete files 2 days old or older
my @files; my $dir; foreach $dir (@ARGV) { # just push files on the list if (-f $dir) { push @files, $_; next; }
next unless -d $dir; # get all the file names in the directory opendir DIR, $dir or die "opendir $dir: $!\n"; push @files, ( map { "$dir/$_" } grep(! /^\.\.?$/, readdir DIR) ) ; }
for (@files) { unless (-f $_) { warn "skipping $_, not a file.\n"; next; } next unless -M $_ >= 2; unlink $_ or die "unlink $_: $!\n"; }
It would be run with a command invocation like:
perl expire_sessions.pl /home/you/catalogs/simple/session
You can give it multiple directory names if you have more than one catalog.
You can adjust this script to do what you wish, of course. Refinements might include reading the file to ``eval'' the session reference and expire only customers who are not members.