[thelist] CGI atime problem

Algian algian at algian.com
Thu Sep 21 14:36:29 CDT 2000


hello evolters,
this script is starting to give me a headache...it's beyond me why it
doesn't work
What it's meant to do is simply delete files that haven't been accessed for
at least 5 hours. The major problem being that when i tried debugging the
code
using print and printing the results i was amazed at the fact that the print
results
were always along these lines:

$now                 $atime          $tot
969567063 - 969490800 = 76263

Now this looks apparently normal if it weren't for the fact that $atime
NEVER changes!!! even if the file was just created like 2 seconds ago
and accessed at that same time to write stuff into the file it still gives
me 969490800
as the last access time...
this leaves me very perplexed.....I'm using windows 98 so maybe that has a
different
"time" than linux but i doubt thats the problem...
any ideas?

thanks
Algian

print "Content-type: text/html\n\n";

#get the time now and set time limit
 my $dir = "f:/apache/htdocs/cgi-bin/temp";
 my $now = time;
 my $secs = 18000;

 #get the file and delete as appropriate
 opendir(TEMP, $dir);
  foreach (readdir(TEMP)) {

   #if its a normal file then delete it after 5 hours of it not being
touched
   if($_ ne "." && $_ ne "..") {
    my $atime = (stat "$dir/$_")[8];
    if (($now - $atime) > $secs) {
     $tot = $now - $atime;
     print "$now - $atime = $tot";
     unlink("$dir/$_");
    }
   }

  }
 closedir(TEMP);

/|\/|\/|\/|\/|\/|\/|\/|\/|\/|\/|\/|\/|\/|\/|\/|\/|\/|\/|\/|\/|\/|\/|\/|\
Alessandro Giannone
Web Anomaly Creator
Edinburgh University
Department of Science & Engineering
\|/\|/\|/\|/\|/\|/\|/\|/\|/\|/\|/\|/\|/\|/\|/\|/\|/\|/\|/\|/\|/\|/\|/\|/





More information about the thelist mailing list