Why no change in fileatime?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • deko

    Why no change in fileatime?

    When I write to a file, the fileatime does not update - how can I get the
    mod date to update when writing to the file?

    //increment counter value by 1
    $counter=file($ ctr);
    $oldct=each($co unter);
    $newct=$oldct[value]+1;
    //write new value to viscounter file
    $fp=fopen($ctr, "w");
    if (flock($fp, LOCK_EX))
    {
    fwrite($fp, $newct);
    flock($fp, LOCK_UN);
    }
    //if cd not get lock, don't count this hit
    fclose($fp);
    echo "counter = ".$newct." visit at ".fileatime($ct r);
    // fileatime($ctr) stays the same...


  • Andy Hassall

    #2
    Re: Why no change in fileatime?

    On Wed, 14 Jul 2004 15:33:04 GMT, "deko" <nospam@hotmail .com> wrote:
    [color=blue]
    >When I write to a file, the fileatime does not update[/color]



    --
    Andy Hassall <andy@andyh.co. uk> / Space: disk usage analysis tool
    http://www.andyh.co.uk / http://www.andyhsoftware.co.uk/space

    Comment

    • Chung Leong

      #3
      Re: Why no change in fileatime?

      Try flushing the stat cache-- clearstatcache( )

      "deko" <nospam@hotmail .com> wrote in message
      news:QmcJc.1035 0$Mx1.9824@news svr25.news.prod igy.com...[color=blue]
      > When I write to a file, the fileatime does not update - how can I get the
      > mod date to update when writing to the file?
      >
      > //increment counter value by 1
      > $counter=file($ ctr);
      > $oldct=each($co unter);
      > $newct=$oldct[value]+1;
      > //write new value to viscounter file
      > $fp=fopen($ctr, "w");
      > if (flock($fp, LOCK_EX))
      > {
      > fwrite($fp, $newct);
      > flock($fp, LOCK_UN);
      > }
      > //if cd not get lock, don't count this hit
      > fclose($fp);
      > echo "counter = ".$newct." visit at ".fileatime($ct r);
      > // fileatime($ctr) stays the same...
      >
      >[/color]


      Comment

      Working...