|
-
Jul 19th, 2004, 11:05 AM
#1
Thread Starter
Frenzied Member
Check file attributes and delete [Resolved]
I need to know how to check the create time on all the files in a certain folder on the server and delete them if they are older than 30 minutes.
Users will be creating reports on the server and then downloading them. I'm giving them 30 minutes to create the report and download it before I remove it from the server so I'm not hogging a bunch of room on the server HD.
I know I have to use unlink to delete the files, but how do I check the file attributes?
Last edited by ober0330; Jul 20th, 2004 at 08:17 AM.
-
Jul 19th, 2004, 11:30 AM
#2
Stuck in the 80s
I know that fileatime() gives the last access time and that filemtime() gives the last time it was modified...but I don't know of anything that'll give the time it was created.
-
Jul 19th, 2004, 11:57 AM
#3
Thread Starter
Frenzied Member
Well the modify time and creation time will be the same since the file will only be downloaded after it has been created.
-
Jul 19th, 2004, 01:56 PM
#4
Stuck in the 80s
Those functions, by the way, take in the name of a file and return a unix timestamp.
-
Jul 19th, 2004, 02:37 PM
#5
Thread Starter
Frenzied Member
Right... and I'll just use maketime to create a timestamp of 30 minutes previous to the current time. If it meets the criteria, it gets the axe. Thanks.
-
Jul 20th, 2004, 04:13 AM
#6
Originally posted by ober0330
Right... and I'll just use maketime to create a timestamp of 30 minutes previous to the current time. If it meets the criteria, it gets the axe. Thanks.
No need to do that. A unix timestamp is in seconds. So all you need to do is define a variable which holds the number of seconds in 30 minutes:
PHP Code:
$seconds_30min = 30 * 60;
$ctime = filectime ($file);
if ($seconds_30min + $ctime < time ())
echo ('file is older than 30 mins');
-
Jul 20th, 2004, 07:32 AM
#7
Thread Starter
Frenzied Member
Ok, next problem... how do I loop through all the files in a folder? I don't know their names other than the fact that it'll be "qry" and then a time/date stamp and then ".csv".
-
Jul 20th, 2004, 07:36 AM
#8
-
Jul 20th, 2004, 08:17 AM
#9
Thread Starter
Frenzied Member
Excellent. Thanks for the tip. It looks like I'll be using scandir().
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|