GoFuckYourself.com - Adult Webmaster Forum

GoFuckYourself.com - Adult Webmaster Forum (https://gfy.com/index.php)
-   Fucking Around & Business Discussion (https://gfy.com/forumdisplay.php?f=26)
-   -   (PHP?) Scan server for rarely used files? (https://gfy.com/showthread.php?t=792807)

cranki 12-17-2007 09:58 AM

(PHP?) Scan server for rarely used files?
 
Is there a way to let php sift through all the files on one's server and delete those which haven't been accessed in a year or so?

I have a shitload of gallery html's which just sit there taking up space...

k0nr4d 12-17-2007 10:07 AM

there's no way to determine what's been accessed. Its possible to do this based on last modified date.

Unless you want it to sift through gigabytes of server logs, in which case php is still not the right language for that

rowan 12-17-2007 10:09 AM

Quote:

Originally Posted by k0nr4d (Post 13526062)
there's no way to determine what's been accessed. Its possible to do this based on last modified date.

Unless you want it to sift through gigabytes of server logs, in which case php is still not the right language for that

FreeBSD records the last time a file was accessed, unless the "noatime" modifier was used when mounting the volume. I'd say Linux also supports this. It shouldn't be too hard to come up with a "find" command that spits out files that have not been touched for a year. I'm too tired to try :)

wanted 12-17-2007 10:12 AM

On what OS are your files located ?

you can always try to use fileatime()

http://ca3.php.net/manual/en/function.fileatime.php

cranki 12-17-2007 10:14 AM

Doesn't this function do that:

http://www.w3schools.com/php/func_fi..._fileatime.asp

?

Or did I misunderstand it?


edit

Quote:

Originally Posted by wanted (Post 13526095)
On what OS are your files located ?

you can always try to use fileatime()

http://ca3.php.net/manual/en/function.fileatime.php

now I gotta put this into a nifty script... unfortunately I'm not too familiar with php :-/

Bro Media - BANNED FOR LIFE 12-17-2007 10:16 AM

fileatime should work, just use it to check, then loop through the directory and unlink() files that haven't been used in x amount of time.


All times are GMT -7. The time now is 03:05 AM.

Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
©2000-, AI Media Network Inc123