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


In reply to Re: deleting a file after loading by arturo
in thread deleting a file after loading by belize

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.