SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    Confirmed Halfwit
    Join Date
    Oct 1999
    Location
    Vancouver, BC, Canada
    Posts
    983
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Finding files >90 days for cron job.

    AAAAHHHH!!!!! Unix is driving me NUTS!


    I'm trying to create a simple cron job using PHP that will go through a series of directories for each customer and delete any files older than 90 days. The directory structure is the same for every customer.. ie:
    Code:
    customer1/TSR
    customer1/ESR/files..
    customer1/EIUUSR/files..
    customer2/TSR/files..
    customer2/ESR/files..
    customer2/EIUUSR/files..
    customer3/TSR/files..
    customer3/ESR/files..
    customer3/EIUUSR/files..
    I thought the easiest way to do this is to simply issue a unix command via PHP, but I just can't get anything to work properly. Here's what I have so far:
    Code:
    find /customer1 -name '*' -mtime +90 -exec rm {} \;
    The problem is that it doesn't seem to find all the files, and it includes the directories themselves (I only want to delete files, not directories).

    Is there a unix pro out there who can suggest anything? Are there any cron job scripts I can look at that might do something similar? Is there a "PHP only" way to do this?

    Thanks,
    Henri Straforelli
    - A simple online WYSIWYG editor for HTML code snippets.
    - Managed Web Hosting - $3.95/month (resellers welcome)
    - Why pay more? $8.95 domains & $9.95 SSL certificates!

  2. #2
    SitePoint Member
    Join Date
    Jun 2001
    Location
    UK
    Posts
    17
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'd suggest looking thru some resources for bash/csh or whatever shell the box supports rather than trying to solve this issue in php.

    - Dibby

  3. #3
    Confirmed Halfwit
    Join Date
    Oct 1999
    Location
    Vancouver, BC, Canada
    Posts
    983
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yes, thanks Dibby. As you can see from the example code that I posted, I have previously attempted to solve this problem by "looking at the docs". At this point, I've spent about 3 hours trying to figure out how to list files older than 90 days. Have you ever read a unix manual? It's not exactly the easiest OS to learn on your own.. which is why I am seeking help.

    I posted in the PHP forum because I suspected that someone might be already doing something similar with their cron jobs.. and I suspect the most knowledgeable unix people would be in this forum.

    Can you suggest somewhere else to post? Is there anyone here who does any file processing that checks to see if a file is older than 90 days?

    Hmm.. the more I think about it.. I'm going to try and do this only with PHP.. there's enough date and file functions to get it going.. at least then I can post in this forum without having someone jump on me to "read the manual".
    - A simple online WYSIWYG editor for HTML code snippets.
    - Managed Web Hosting - $3.95/month (resellers welcome)
    - Why pay more? $8.95 domains & $9.95 SSL certificates!

  4. #4
    SitePoint Member
    Join Date
    Jun 2001
    Location
    UK
    Posts
    17
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'm really terribly sorry, I didnt mean for it to come across that way.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •