(PHP?) Scan server for rarely used files?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • cranki
    Confirmed User
    • Feb 2005
    • 5162

    #1

    (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
    Confirmed User
    • Aug 2006
    • 9231

    #2
    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
    Mechanical Bunny Media
    Mechbunny Tube Script | Mechbunny Webcam Aggregator Script | Custom Web Development

    Comment

    • rowan
      Too lazy to set a custom title
      • Mar 2002
      • 17393

      #3
      Originally posted by k0nr4d
      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

      Comment

      • wanted
        Certified Asshole
        • Jan 2003
        • 896

        #4
        On what OS are your files located ?

        you can always try to use fileatime()

        http://ca3.php.net/manual/en/function.fileatime.php
        Last edited by wanted; 12-17-2007, 08:14 AM.
        Living the dream.

        Comment

        • cranki
          Confirmed User
          • Feb 2005
          • 5162

          #5
          Doesn't this function do that:

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

          ?

          Or did I misunderstand it?


          edit

          Originally posted by wanted
          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 :-/
          Last edited by cranki; 12-17-2007, 08:16 AM.

          Comment

          • Bro Media - BANNED FOR LIFE
            MOBILE PORN: IMOBILEPORN
            • Jan 2004
            • 16502

            #6
            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.

            Comment

            Working...