Hi all,

I am currenlt working on a web project where a file is created on a linux server when the user has entred their results.
If your familiar with the biology BLAST tool it works in the same format.

What i want to do now though, as with BLAST, is to delete the files after one day, so the files dont eventually swamp the server.
I have read the nodes about deleting files and so now have:

#!/usr/bin/perl -w use strict; use warnings; my $dir = "/home/march05/msc0516/public_html/Blast/updated/"; chdir $dir; opendir(DIR,"$dir") or die "Could not open $dir:$!"; while (my $file=readdir(DIR)) { my $age= -M $file; unlink $file if int($age) > 1; } closedir(DIR);

But as i have read, the -M option only looks for the time from when it was last modified. Can i therefore look for the creation date (understanding that there is no real time of creation format on a unix server), or am i still ok using this option.

Secondly: i want this deleteFile.pl script to delete the files automatically after 1 day and so dont want to have to invoke it myself. Is it possible to call the script each time the first web page is loaded or use the cron method to call it say everyday, though im not really sure how that works.

cheers,
MonkPaul


In reply to Automatically delete files by MonkPaul

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.