Automatically delete files from webfolder at regular intervals- HELP NEEDED!

Discussion in 'Site & Server Administration' started by gaurav_jain03, Apr 25, 2008.

  1. #1
    hello

    i have a web folder in which files are created at regular intervals .
    Is it possible to automatically delete the files which are 1 hour older from that folder ?
    i hope i can get solution from experienced members here at DP :)
     
    gaurav_jain03, Apr 25, 2008 IP
  2. bucasia

    bucasia Peon

    Messages:
    50
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #2
    You can certainly delete files that haven't been modified in the last 24 hours (assuming this is linux ...)

    find . -mtime +1 -exec rm {} \;

    (obviously be careful where you run this!)

    Would need to think a bit more about an hour old though ...

    Matt
     
    bucasia, Apr 25, 2008 IP
  3. gaurav_jain03

    gaurav_jain03 Well-Known Member

    Messages:
    402
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    110
    #3
    are you sure about this.. because i dont want to loose my other data.....
    i want to delete files of folder www/gaurav/temp - for example .. now can you tell me exact code and how to run it .. i am new to linux
     
    gaurav_jain03, Apr 25, 2008 IP
  4. bucasia

    bucasia Peon

    Messages:
    50
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Hi there,

    I suggest you create some temporary files and folders and have a play with these commands before you run them on any important data to find out what they are going to do.

    Also, make sure you've got a current backup of any important data.

    Regards - Matt
     
    bucasia, Apr 26, 2008 IP
  5. gaurav_jain03

    gaurav_jain03 Well-Known Member

    Messages:
    402
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    110
    #5
    hey my friend made me this script for me....
    The problem is that it has constant folder address.. and i dont want that.. what i want is that in whichever folder the script is placed it should check the files and delete them without deleting itself!
     
    gaurav_jain03, Apr 26, 2008 IP