Do you have a question? Post it now! No Registration Necessary. Now with pictures!
- Posted on
- Deleting old files using stat
June 14, 2008, 1:57 am
rate this thread
the epoch) value returned by stat($filename) to find files (session
ids created by my program) that have not been accessed in 24 hours and
But before I do this I thought I would ask if there was a better way
than itterating over all the files in a folder (could be 1000's of
them if the site is busy) and running stat on each and determining if
24 hours has passed?
The other question I had, if I do end up doing this, I should be able
to determine if 24 hours has passed if I subtract the atime from time
to get the number of seconds passed since it was last accessed,
Re: Deleting old files using stat
Nope. About the only other option would be running some daemon that used
FAM or some other change-notify system to keep track of which files were
opened, but that would almost certainly be more expensive.
The -A operator is provided for exactly this sort of job.
Although few may originate a policy, we are all able to judge it.
Pericles of Athens, c.430 B.C.