in reply to deleting a file after loading
I guess this depends on your setup, but what you might do is keep the images for, say 15 minutes and then delete them. You could do this with a routine in your image-generating CGI script (as I understand your setup), or (better for so many reasons) you could write a cron job that deletes files that are 15 minutes (or whatever value makes sense) old or older. Perl's -M filetest returns the amount of time, in days, since the file was modified. Assuming nothing's gonna change your files other than creation, the value of -M file will tell you how long since file was created.
Here's a suitable cron script ... UNTESTED, so check it over =)
#!/usr/bin/perl -w # delold.pl -- deletes files older than a certain # of minutes use strict; # this is a bit clunky; ideally you'd use the Getopt::Std module, but +hey. my $maxage = shift || 15; #you can call the script with "delold.pl 20 +" and it will delete files that #haven't been modified for 20 minutes. my $dir = shift || "/usr/www/images/temp"; # or wherever makes sense opendir DIR, $dir or die "Can't open $dir: $!\n"; while (my $file = readdir DIR) { next unless -f "$dir/$file"; # skip directories, etc. unlink "$dir/$file" if -M "$dir/$file" > ($maxage / 1440); } closedir DIR;
Philosophy can be made out of anything. Or less -- Jerry A. Fodor
|
|---|