MonkPaul has asked for the wisdom of the Perl Monks concerning the following question:
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);
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
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Automatically delete files
by holli (Abbot) on Aug 02, 2005 at 14:41 UTC | |
by data64 (Chaplain) on Aug 02, 2005 at 15:03 UTC | |
by fishbot_v2 (Chaplain) on Aug 02, 2005 at 15:42 UTC | |
by MonkPaul (Friar) on Aug 02, 2005 at 14:48 UTC | |
|
Re: Automatically delete files
by sparkyichi (Deacon) on Aug 02, 2005 at 14:47 UTC | |
by MonkPaul (Friar) on Aug 02, 2005 at 14:51 UTC | |
by sparkyichi (Deacon) on Aug 02, 2005 at 14:58 UTC | |
by MonkPaul (Friar) on Aug 02, 2005 at 15:13 UTC | |
|
Re: Automatically delete files
by bluto (Curate) on Aug 02, 2005 at 15:54 UTC | |
|
Re: Automatically delete files
by davidrw (Prior) on Aug 02, 2005 at 15:19 UTC | |
by MonkPaul (Friar) on Aug 02, 2005 at 15:53 UTC | |
by davidrw (Prior) on Aug 02, 2005 at 16:30 UTC |