SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Addict Latox's Avatar
    Join Date
    Dec 2008
    Location
    Australia
    Posts
    389
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    PHP Script Deletion

    I want to set up a script which I can run at about 4PM every day on a cron, to delete folders.

    I have a script which puts files into a folder according to date.

    For example:

    The date is 4th May, the folder name 04_05
    The date is 5th May, the folder name 05_05

    So on and so forth.

    On the 5th May, I want a cron to run to delete the folder 04_05 and all files under it (as the folder the day before is no use now as todays folder has been created and everything runs through this.)

    Basically, I just want a script which will run on day 2, and delete the day 1 folder.

    Any help is very much appreciated.
    :-)

  2. #2
    Follow Me On Twitter: @djg gold trophysilver trophybronze trophy Dan Grossman's Avatar
    Join Date
    Aug 2000
    Location
    Philadephia, PA
    Posts
    20,578
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    exec("rm -rf /home/example/" date("d_m"strtotime("yesterday"))); 
    Although you could easily skip the PHP here and code the date calculation as a pure bash script

  3. #3
    SitePoint Addict Latox's Avatar
    Join Date
    Dec 2008
    Location
    Australia
    Posts
    389
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yeah I've been using shell to delete the folders so far, the folders reach about 100GB of disk space per folder per day... getting too busy I need to start freeing up space daily using a cron.

    Thanks for your help, I will have a go with this. Much appreciated.
    :-)


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
  •