1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Need a cron job to delete files and subdirectories

Discussion in 'Content Management' started by Decipher442, Oct 11, 2011.

  1. #1
    I'm looking for a cron job that will delete files and sub-directories within a directory on a daily basis...

    Example:
    www.mysite.com/directory/ <-- the cron job is made to delete all files and sub-directories created inside this sub-directory on a daily basis.
    www.mysite.com/directory/file1.php <-- deleted daily
    www.mysite.com/directory/1/ <-- deleted daily

    I would use this cron but i think it only deletes the files with in the directory and doesnt delete the sub-directories..
    find /directory -maxdepth 1 -type f -mtime +7 -exec rm -f {} \;
    Code (markup):

     
    Last edited: Oct 11, 2011
    Decipher442, Oct 11, 2011 IP
  2. borgy

    borgy Active Member

    Messages:
    49
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    91
    #2
    Try to increas the maxdepth parameter to 3 or 4
     
    borgy, Oct 20, 2011 IP