PHP fileatime -> Always 1 o'clock in the morning
I wrote a routine to delete all files in a folder that have not been used for the last x days.
I am using the functionfileatime()
[or more precisely the DirectoryIterator functiongetATime()
]
When debugging, I noticed that the last access time for all the files was 1 o'clock this morning.
This is the time when the server is automatically backed-up.
So the question is... How to find out the last time the file was accessed, by a user and not the automatic back up.
Any help would be appreciated.
David
Answer
Solution:
This is the solution I came up with. Whenever a user accesses a file, I copy the file to a new name and delete the older version. This sets a new modification time.
Independently, in a separate routine, I look through all files in the folder and delete any folders that have not been accessed (modified) since X days.